From c66c316b957d80dcb623a830c587337eddeaa927 Mon Sep 17 00:00:00 2001 From: Tom French Date: Mon, 9 May 2022 11:31:07 +0100 Subject: [PATCH] test: fix test to properly pass in invalid inputs individually --- packages/loot-core/src/server/timestamp.test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/loot-core/src/server/timestamp.test.js b/packages/loot-core/src/server/timestamp.test.js index b242de1..4c72847 100644 --- a/packages/loot-core/src/server/timestamp.test.js +++ b/packages/loot-core/src/server/timestamp.test.js @@ -24,7 +24,7 @@ describe('Timestamp', function() { describe('parsing', function() { it('should not parse', function() { - var invalid = [ + const invalidInputs = [ null, undefined, {}, @@ -40,26 +40,26 @@ describe('Timestamp', function() { '9999-12-31T23:59:59.999Z-10000-FFFFFFFFFFFFFFFF', '9999-12-31T23:59:59.999Z-FFFF-10000000000000000' ]; - for (var i = 0; i < invalid.length; i++) { - expect(Timestamp.parse(invalid)).toBe(null); + for (const invalidInput of invalidInputs) { + expect(Timestamp.parse(invalidInput)).toBe(null); } }); it('should parse', function() { - var valid = [ + var validInputs = [ '1970-01-01T00:00:00.000Z-0000-0000000000000000', '2015-04-24T22:23:42.123Z-1000-0123456789ABCDEF', '9999-12-31T23:59:59.999Z-FFFF-FFFFFFFFFFFFFFFF' ]; - for (var i = 0; i < valid.length; i++) { - var parsed = Timestamp.parse(valid[i]); + for (const validInput of validInputs) { + var parsed = Timestamp.parse(validInput); expect(typeof parsed).toBe('object'); expect(parsed.millis() >= 0).toBeTruthy(); expect(parsed.millis() < 253402300800000).toBeTruthy(); expect(parsed.counter() >= 0).toBeTruthy(); expect(parsed.counter() < 65536).toBeTruthy(); expect(typeof parsed.node()).toBe('string'); - expect(parsed.toString()).toBe(valid[i]); + expect(parsed.toString()).toBe(validInput); } }); });