mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 01:02:01 +03:00
test: add edge case tests for isCalendarUnit
Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
parent
c958f30662
commit
336758c9e9
1 changed files with 27 additions and 0 deletions
|
|
@ -204,5 +204,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