Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import assert from "node:assert/strict";
import { createRequire } from "node:module";
import test from "node:test";
import {
byCountry,
Expand All @@ -10,6 +11,8 @@ import {
random,
} from "../src";

const requirePackage = createRequire(__filename);

test("exports the generated IP list", () => {
assert.equal(ips.length, 4312);
assert.equal(countries.length, 20);
Expand Down Expand Up @@ -63,3 +66,12 @@ test("validates country input", () => {
getByCountry(123 as unknown as string);
}, TypeError);
});

test("resolves package exports", () => {
const googleIps = requirePackage("google-ips") as typeof import("../src");
const data = requirePackage("google-ips/data") as typeof import("../data/google-ips.json");

assert.equal(googleIps.ips.length, 4312);
assert.equal(data.ips.length, googleIps.ips.length);
assert.equal(googleIps.findCountry("118.174.25.251"), "Thailand");
});
Loading