-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(react-pagination): add tests for usepagination (#150)
* test(react-pagination): add tests for usepagination * use v8 instead of c8 * Apply suggestions from code review * build(react-pagination): keep it public * check if throwing error is the issue * bring back error * try adding dependson * try adding turbo json to pagination package * try building first * bring back turbo jsins * try adding turbo json to pagination package * use debug overlay * remove turbos * bring back turbo.jsn * ci(turborepo): build dependencies before running tests * style(react-pagination): apply prettier formatting * ci(turborepo): make test depend on ^build --------- Co-authored-by: Thijs Daniels <[email protected]>
- Loading branch information
1 parent
574e593
commit e3014cb
Showing
12 changed files
with
350 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@codedazur/react-pagination": major | ||
"@codedazur/essentials": minor | ||
--- | ||
|
||
@codedazur/essentials - assert function is added | ||
|
||
@codedazur/react-pagination - first release and adding tests |
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,16 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import { AssertionError, assert } from "./assert"; | ||
|
||
describe("assert", () => { | ||
it("should throw an Assertion Error when the condition is false", () => { | ||
expect(() => assert(false)).toThrowError(new AssertionError()); | ||
}); | ||
it("should throw an Assertion Error with provided message when the condition is false", () => { | ||
expect(() => | ||
assert(false, "These pretzels are making me thirsty!") | ||
).toThrowError(new AssertionError("These pretzels are making me thirsty!")); | ||
}); | ||
it("should not throw an Assertion Error when the condition is true", () => { | ||
expect(() => assert(true)).not.toThrow(); | ||
}); | ||
}); |
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,13 @@ | ||
export class AssertionError extends Error { | ||
constructor(message?: string) { | ||
super(message); | ||
this.name = "AssertionError"; | ||
} | ||
} | ||
|
||
export function assert( | ||
condition: unknown, | ||
errorMessage?: string | ||
): asserts condition { | ||
if (condition === false) throw new AssertionError(errorMessage); | ||
} |
Oops, something went wrong.