Skip to content

Commit

Permalink
add red test for gitignore scope logic
Browse files Browse the repository at this point in the history
  • Loading branch information
DaAitch committed Jun 16, 2024
1 parent ef2464d commit 5989d4a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/knip/fixtures/gitignore-scope/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixtures/
2 changes: 2 additions & 0 deletions packages/knip/fixtures/gitignore-scope/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import glob from 'glob'
glob.escape('something')
7 changes: 7 additions & 0 deletions packages/knip/fixtures/gitignore-scope/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@fixtures/gitignore-scope",
"main": "index.mjs",
"dependencies": {
"glob": "^10.3.12"
}
}
21 changes: 21 additions & 0 deletions packages/knip/test/gitignore-scope.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test } from 'bun:test';
import assert from 'node:assert/strict';
import { main } from '../src/index.js';
import { resolve } from '../src/util/path.js';
import baseArguments from './helpers/baseArguments.js';

const cwd = resolve('fixtures/gitignore-scope');

test('test acceptance: cwd should contain "fixtures" in path or the test obsolete', () => {
assert(cwd.includes('/fixtures/'))
})

test('Obey gitignore-scope logic', async () => {
const { issues } = await main({
...baseArguments,
cwd,
gitignore: true,
});

assert.equal(issues.dependencies, {});
});

0 comments on commit 5989d4a

Please sign in to comment.