mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibJS: Test function toBeCloseTo takes an optional precision argument
Modeled after the equivalent Jest function. https://jestjs.io/docs/expect#tobeclosetonumber-numdigits
This commit is contained in:
parent
73c8650ea0
commit
c97eec030c
2 changed files with 17 additions and 3 deletions
|
@ -36,6 +36,16 @@ test("toBeCloseTo", () => {
|
|||
expect(1).not.toBeCloseTo(1.00001);
|
||||
expect(1).toBeCloseTo(1.000001);
|
||||
|
||||
expect(1).not.toBeCloseTo(1.001, 3);
|
||||
expect(1).toBeCloseTo(1.001, 2);
|
||||
expect(1).not.toBeCloseTo(0, 0);
|
||||
expect(6).toBeCloseTo(10, -1);
|
||||
expect(125).toBeCloseTo(100, -2);
|
||||
expect(3.14159).toBeCloseTo(3.14158, 4);
|
||||
expect(() => {
|
||||
expect(1).toBeCloseTo(1, "foo").toThrow(ExpectationError);
|
||||
}).toThrow(ExpectationError);
|
||||
|
||||
[
|
||||
["foo", 1],
|
||||
[1, "foo"],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue