diff --git a/test/index.test.ts b/test/index.test.ts index 09ef1a0..e506a97 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -1,4 +1,5 @@ import assert from "node:assert/strict"; +import { createRequire } from "node:module"; import test from "node:test"; import { byCountry, @@ -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); @@ -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"); +});