From 2f3689713b07b002c5cb45431de9f312e9fed5a7 Mon Sep 17 00:00:00 2001 From: Matt McCherry Date: Tue, 10 Dec 2024 11:31:16 +0000 Subject: [PATCH] add tests for falsy values --- spec/core/matchers/toBeNullishSpec.js | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/spec/core/matchers/toBeNullishSpec.js b/spec/core/matchers/toBeNullishSpec.js index 29c41fdc..5f70d1a8 100644 --- a/spec/core/matchers/toBeNullishSpec.js +++ b/spec/core/matchers/toBeNullishSpec.js @@ -16,4 +16,42 @@ describe('toBeNullish', function() { const result = matcher.compare('foo'); expect(result.pass).toBe(false); }); + + describe('falsy values', () => { + it('fails for 0', function() { + const matcher = jasmineUnderTest.matchers.toBeNullish(); + const result = matcher.compare(0); + expect(result.pass).toBe(false); + }); + + it('fails for -0', function() { + const matcher = jasmineUnderTest.matchers.toBeNullish(); + const result = matcher.compare(-0); + expect(result.pass).toBe(false); + }); + + it('fails for empty string', function() { + const matcher = jasmineUnderTest.matchers.toBeNullish(); + const result = matcher.compare(''); + expect(result.pass).toBe(false); + }); + + it('fails for false', function() { + const matcher = jasmineUnderTest.matchers.toBeNullish(); + const result = matcher.compare(false); + expect(result.pass).toBe(false); + }); + + it('fails for NaN', function() { + const matcher = jasmineUnderTest.matchers.toBeNullish(); + const result = matcher.compare(NaN); + expect(result.pass).toBe(false); + }); + + it('fails for 0n', function() { + const matcher = jasmineUnderTest.matchers.toBeNullish(); + const result = matcher.compare(BigInt(0)); + expect(result.pass).toBe(false); + }); + }); });