mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 22:41:58 +03:00
add isCalendarUnit edge case tests
This commit is contained in:
parent
8f200bcd61
commit
a384b98dcb
1 changed files with 27 additions and 0 deletions
|
|
@ -178,5 +178,32 @@ describe("datetime", () => {
|
||||||
expect(isCalendarUnit("minute", 1)).toBe(false);
|
expect(isCalendarUnit("minute", 1)).toBe(false);
|
||||||
expect(isCalendarUnit("unit:meter", 1)).toBe(false);
|
expect(isCalendarUnit("unit:meter", 1)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should handle edge cases for amount", () => {
|
||||||
|
expect(isCalendarUnit("day", 0)).toBe(true);
|
||||||
|
expect(isCalendarUnit("day", Number.MAX_SAFE_INTEGER)).toBe(true);
|
||||||
|
expect(isCalendarUnit("day", Number.MIN_SAFE_INTEGER)).toBe(true);
|
||||||
|
|
||||||
|
expect(isCalendarUnit("day", NaN)).toBe(false);
|
||||||
|
expect(isCalendarUnit("day", Infinity)).toBe(false);
|
||||||
|
expect(isCalendarUnit("day", -Infinity)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle edge cases for unitId string format", () => {
|
||||||
|
expect(isCalendarUnit("", 1)).toBe(false);
|
||||||
|
expect(isCalendarUnit(":", 1)).toBe(false);
|
||||||
|
|
||||||
|
// string.split(":") behavior:
|
||||||
|
expect(isCalendarUnit("time:month", 1)).toBe(true);
|
||||||
|
expect(isCalendarUnit(":day", 1)).toBe(true);
|
||||||
|
expect(isCalendarUnit("day:", 1)).toBe(false);
|
||||||
|
expect(isCalendarUnit("a:day:c", 1)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return false for case-sensitive mismatch", () => {
|
||||||
|
expect(isCalendarUnit("Day", 1)).toBe(false);
|
||||||
|
expect(isCalendarUnit("YEAR", 1)).toBe(false);
|
||||||
|
expect(isCalendarUnit("MONTH", 1)).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue