mirror of
https://github.com/tale/headplane.git
synced 2026-08-21 10:16:37 +00:00
refactor: extract isNoExpiry utility for zero-time handling
Go's time.Time{} serialises to '0001-01-01T00:00:00Z' which headscale
may return instead of null for tagged nodes (juanfont/headscale#3170).
Commit extracts the the existing inline check into a shared function for reuse.
No behavior change — mapNodes() already handled both variants.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { isNoExpiry } from "~/utils/node-info";
|
||||
|
||||
describe("isNoExpiry", () => {
|
||||
test("returns true for null", () => {
|
||||
expect(isNoExpiry(null)).toBe(true);
|
||||
});
|
||||
|
||||
test("returns true for undefined", () => {
|
||||
expect(isNoExpiry(undefined)).toBe(true);
|
||||
});
|
||||
|
||||
test("returns true for Go zero-time ISO format", () => {
|
||||
expect(isNoExpiry("0001-01-01T00:00:00Z")).toBe(true);
|
||||
});
|
||||
|
||||
test("returns true for Go zero-time space format", () => {
|
||||
expect(isNoExpiry("0001-01-01 00:00:00")).toBe(true);
|
||||
});
|
||||
|
||||
test("returns false for a real future expiry", () => {
|
||||
expect(isNoExpiry("2030-01-01T00:00:00Z")).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false for a real past expiry", () => {
|
||||
expect(isNoExpiry("2020-01-01T00:00:00Z")).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user