-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respond to PR feedback and add tests
- Loading branch information
Showing
2 changed files
with
86 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { expect } from "chai"; | ||
|
||
import FileFilter, { FilterType } from "../"; | ||
import IncludeFilter from "../IncludeFilter"; | ||
import ExcludeFilter from "../ExcludeFilter"; | ||
import FuzzyFilter from "../FuzzyFilter"; | ||
|
||
describe("FileFilter", () => { | ||
describe("equals", () => { | ||
it("is backwards compatible when no type argument is provided", () => { | ||
// Arrange | ||
const fileFilterNoType = new FileFilter("Annotation name", "test value"); | ||
const fileFilterWithType = new FileFilter( | ||
"Annotation name", | ||
"test value", | ||
FilterType.DEFAULT | ||
); | ||
|
||
// Act/Assert | ||
expect(fileFilterNoType.equals(fileFilterWithType)); | ||
}); | ||
it("returns true for include filter subtype and parent class", () => { | ||
// Arrange | ||
const fileFilterIncludeConstructor = new IncludeFilter("Annotation name"); | ||
const fileFilterParentConstructor = new FileFilter( | ||
"Annotation name", | ||
"", | ||
FilterType.ANY | ||
); | ||
|
||
// Act/Assert | ||
expect(fileFilterIncludeConstructor.equals(fileFilterParentConstructor)); | ||
}); | ||
it("returns true for exclude filter subtype and parent class", () => { | ||
// Arrange | ||
const fileFilterExcludeConstructor = new ExcludeFilter("Annotation name"); | ||
const fileFilterParentConstructor = new FileFilter( | ||
"Annotation name", | ||
"", | ||
FilterType.EXCLUDE | ||
); | ||
|
||
// Act/Assert | ||
expect(fileFilterExcludeConstructor.equals(fileFilterParentConstructor)); | ||
}); | ||
it("returns true for fuzzy filter subtype and parent class", () => { | ||
// Arrange | ||
const fileFilterFuzzyConstructor = new FuzzyFilter( | ||
"Annotation name", | ||
"annotation value" | ||
); | ||
const fileFilterParentConstructor = new FileFilter( | ||
"Annotation name", | ||
"annotation value", | ||
FilterType.FUZZY | ||
); | ||
|
||
// Act/Assert | ||
expect(fileFilterFuzzyConstructor.equals(fileFilterParentConstructor)); | ||
}); | ||
it("returns false for different filter subtypes", () => { | ||
// Arrange | ||
const fileFilter = new FileFilter("Annotation name", "annotation value"); | ||
const fileFilterFuzzyConstructor = new FuzzyFilter( | ||
"Annotation name", | ||
"annotation value" | ||
); | ||
const fileFilterExcludeConstructor = new ExcludeFilter("Annotation name"); | ||
const fileFilterIncludeConstructor = new IncludeFilter("Annotation name"); | ||
|
||
// Act/Assert | ||
expect(!fileFilterFuzzyConstructor.equals(fileFilter)); | ||
expect(!fileFilterIncludeConstructor.equals(fileFilterExcludeConstructor)); | ||
}); | ||
}); | ||
}); |