Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed May 22, 2024
1 parent 3b1df04 commit e23e2af
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {parseIp, normalizeIp, max4, max6, ipVersion} from "./index.ts";
import {parseIp, normalizeIp, max4, max6, ipVersion, stringifyIp} from "./index.ts";

function jsonStringifyWithBigInt(parsedIp, _?, ...args) {
return JSON.stringify(parsedIp, (_, value) => typeof value === "bigint" ? value.toString() : value, ...args);
Expand Down Expand Up @@ -60,6 +60,9 @@ test("parseIp and stringifyIp", () => {
expect(() => parseIp("")).toThrow();
expect(() => parseIp("1")).toThrow();
expect(jsonStringifyWithBigInt(parseIp("::"))).toEqual(`{"number":"0","version":6}`);

const {number, version} = parseIp("255.255.255.255");
expect(stringifyIp({number, version})).toEqual("255.255.255.255");
});

test("ipVersion", () => {
Expand Down

0 comments on commit e23e2af

Please sign in to comment.