-
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.
Add checker() function that returns a named checker
- Loading branch information
Showing
5 changed files
with
41 additions
and
3 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
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,17 @@ | ||
const BlorkError = require("../lib/errors/BlorkError"); | ||
const { checker } = require("../lib/exports"); | ||
|
||
// Tests. | ||
describe("exports.check()", () => { | ||
test("Getting and using a checker works correctly", () => { | ||
expect(checker("string")("abc")).toBe(true); | ||
expect(checker("string")(123)).toBe(false); | ||
}); | ||
test("Throw BlorkError if passing a non-string", () => { | ||
expect(() => checker(123)).toThrow(BlorkError); | ||
expect(() => checker(false)).toThrow(BlorkError); | ||
}); | ||
test("Throw BlorkError if asking for non-existant checker", () => { | ||
expect(() => checker("abc")).toThrow(BlorkError); | ||
}); | ||
}); |