-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix ignored paths check Seems since using files API in #54, `IGNORED` stopped to work * Add test checking undefined path * Add test checking undefined path --------- Co-authored-by: Pascal <pascal.gruen@gmail.com>
- Loading branch information
Showing
5 changed files
with
584 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { parseIgnored } from "./index"; | ||
|
||
describe("parseIgnored", () => { | ||
it.each(["", null, undefined, "\r\n", "\n", "#", "#file"])( | ||
"doesn't ignore when no patterns to ignore provided (%s)", | ||
input => { | ||
// when | ||
const isIgnored = parseIgnored(input); | ||
|
||
// then | ||
expect(isIgnored("file")).toBe(false); | ||
} | ||
); | ||
|
||
it("ignores ordinary patterns", () => { | ||
// when | ||
const isIgnored = parseIgnored( | ||
"**/src/integration/**\n**/src/test/**\n**/src/testFixtures/**" | ||
); | ||
|
||
// then | ||
expect(isIgnored("file")).toBe(false); | ||
expect(isIgnored("src/test/file")).toBe(true); | ||
expect(isIgnored("codebase/src/testFixtures/file")).toBe(true); | ||
}); | ||
|
||
it.each([null, undefined, "/dev/null"])( | ||
"ignores some patterns by default (%s)", | ||
alwaysIgnoredInput => { | ||
// when | ||
const isIgnored = parseIgnored( | ||
"**/src/integration/**\n**/src/test/**\n**/src/testFixtures/**" | ||
); | ||
|
||
// then | ||
expect(isIgnored(alwaysIgnoredInput)).toBe(true); | ||
} | ||
); | ||
|
||
it("accepts negated patterns", () => { | ||
// when | ||
const isIgnored = parseIgnored(".*\n!.gitignore\nyarn.lock\ngenerated/**"); | ||
|
||
// then | ||
expect(isIgnored(".git")).toBe(true); | ||
expect(isIgnored(".gitignore")).toBe(false); | ||
expect(isIgnored("yarn.lock")).toBe(true); | ||
expect(isIgnored("generated/source")).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.