Skip to content

Commit 8bf5187

Browse files
committed
Update the test suite of isNumber
1 parent 9570b78 commit 8bf5187

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/validation/drivers/validators/isNumber.spec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ describe("isNumber", () => {
1010
expect(isNumber(123456789)).to.equal(123456789)
1111
})
1212

13+
it("should parse a string containing a number into a number", () => {
14+
expect(isNumber("1")).to.equal(1)
15+
expect(isNumber("0")).to.equal(0)
16+
expect(isNumber("0.001")).to.equal(0.001)
17+
expect(isNumber("-12423435.1")).to.equal(-12423435.1)
18+
expect(isNumber("+100")).to.equal(100)
19+
})
20+
1321
it("should return a validation error if input is not a number", () => {
1422
expectToThrowCustomClass(() => isNumber({}), ValidationError)
15-
expectToThrowCustomClass(() => isNumber("1"), ValidationError)
16-
expectToThrowCustomClass(() => isNumber("0"), ValidationError)
1723
expectToThrowCustomClass(() => isNumber("das"), ValidationError)
1824
expectToThrowCustomClass(() => isNumber("true"), ValidationError)
1925
expectToThrowCustomClass(() => isNumber("false"), ValidationError)

0 commit comments

Comments
 (0)