From 1d86ca3a68cb5af1563cc27d328c72ec0e5c22b5 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 2 Oct 2024 15:50:51 +0200 Subject: [PATCH] test: add dependency tests --- package.json | 4 +++ pnpm-lock.yaml | 37 ++++++++++++++++++++++++ test/__snapshots__/fixtures.test.ts.snap | 13 +++++---- test/fixtures/deps/config.ts | 2 ++ test/fixtures/deps/consola.ts | 3 ++ test/fixtures/deps/etag.ts | 7 +++++ test/fixtures/deps/index.ts | 6 ++++ test/fixtures/deps/mime.ts | 3 ++ test/fixtures/deps/moment.ts | 8 +++++ test/fixtures/deps/typescript.ts | 3 ++ test/fixtures/exotic/index.ts | 6 ---- test/native/deno.test.ts | 2 +- test/native/node.test.ts | 2 +- 13 files changed, 83 insertions(+), 13 deletions(-) create mode 100644 test/fixtures/deps/config.ts create mode 100644 test/fixtures/deps/consola.ts create mode 100644 test/fixtures/deps/etag.ts create mode 100644 test/fixtures/deps/index.ts create mode 100644 test/fixtures/deps/mime.ts create mode 100644 test/fixtures/deps/moment.ts create mode 100644 test/fixtures/deps/typescript.ts delete mode 100644 test/fixtures/exotic/index.ts diff --git a/package.json b/package.json index 4a1b8d85..6663c056 100644 --- a/package.json +++ b/package.json @@ -93,13 +93,17 @@ "babel-plugin-parameter-decorator": "^1.0.16", "changelogen": "^0.5.7", "config": "^3.3.12", + "consola": "^3.2.3", "destr": "^2.0.3", "escape-string-regexp": "^5.0.0", "eslint": "^9.11.0", "eslint-config-unjs": "^0.4.1", "estree-walker": "^3.0.3", + "etag": "^1.8.1", "fast-glob": "^3.3.2", + "mime": "^4.0.4", "mlly": "^1.7.1", + "moment-timezone": "^0.5.45", "nano-jsx": "^0.1.0", "pathe": "^1.1.2", "pkg-types": "^1.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 17f34255..22b34eb0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -89,6 +89,9 @@ importers: config: specifier: ^3.3.12 version: 3.3.12 + consola: + specifier: ^3.2.3 + version: 3.2.3 destr: specifier: ^2.0.3 version: 2.0.3 @@ -104,12 +107,21 @@ importers: estree-walker: specifier: ^3.0.3 version: 3.0.3 + etag: + specifier: ^1.8.1 + version: 1.8.1 fast-glob: specifier: ^3.3.2 version: 3.3.2 + mime: + specifier: ^4.0.4 + version: 4.0.4 mlly: specifier: ^1.7.1 version: 1.7.1 + moment-timezone: + specifier: ^0.5.45 + version: 0.5.45 nano-jsx: specifier: ^0.1.0 version: 0.1.0 @@ -1308,6 +1320,10 @@ packages: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} + etag@1.8.1: + resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==} + engines: {node: '>= 0.6'} + events@3.3.0: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} @@ -1706,6 +1722,11 @@ packages: resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} engines: {node: '>= 0.6'} + mime@4.0.4: + resolution: {integrity: sha512-v8yqInVjhXyqP6+Kw4fV3ZzeMRqEW6FotRsKXjRS5VMTNIuXsdRoAvklpoRgSqXm6o9VNH4/C0mgedko9DdLsQ==} + engines: {node: '>=16'} + hasBin: true + mimic-fn@4.0.0: resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} engines: {node: '>=12'} @@ -1745,6 +1766,12 @@ packages: mlly@1.7.1: resolution: {integrity: sha512-rrVRZRELyQzrIUAVMHxP97kv+G786pHmOKzuFII8zDYahFBS7qnHh2AlYSl1GAHhaMPCz6/oHjVMcfFYgFYHgA==} + moment-timezone@0.5.45: + resolution: {integrity: sha512-HIWmqA86KcmCAhnMAN0wuDOARV/525R2+lOLotuGFzn4HO+FH+/645z2wx0Dt3iDv6/p61SIvKnDstISainhLQ==} + + moment@2.30.1: + resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==} + mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} engines: {node: '>=4'} @@ -3693,6 +3720,8 @@ snapshots: esutils@2.0.3: {} + etag@1.8.1: {} + events@3.3.0: {} execa@8.0.1: @@ -4057,6 +4086,8 @@ snapshots: dependencies: mime-db: 1.52.0 + mime@4.0.4: {} + mimic-fn@4.0.0: {} min-indent@1.0.1: {} @@ -4091,6 +4122,12 @@ snapshots: pkg-types: 1.2.0 ufo: 1.5.4 + moment-timezone@0.5.45: + dependencies: + moment: 2.30.1 + + moment@2.30.1: {} + mri@1.2.0: {} mrmime@2.0.0: {} diff --git a/test/__snapshots__/fixtures.test.ts.snap b/test/__snapshots__/fixtures.test.ts.snap index cacd2844..8b4771f7 100644 --- a/test/__snapshots__/fixtures.test.ts.snap +++ b/test/__snapshots__/fixtures.test.ts.snap @@ -6,6 +6,14 @@ exports[`fixtures > circular > stdout 1`] = `"a b c"`; exports[`fixtures > data-uri > stdout 1`] = `""`; +exports[`fixtures > deps > stdout 1`] = ` +"npm:config: true +npm:etag: true +npm:mime: true +npm:typescript: true +npm:moment-timezone true" +`; + exports[`fixtures > env > stdout 1`] = ` "process.env true process.env.TEST true @@ -43,11 +51,6 @@ exports[`fixtures > esm > stdout 1`] = ` }" `; -exports[`fixtures > exotic > stdout 1`] = ` -"Typescript: true -Config: true" -`; - exports[`fixtures > hashbang > stdout 1`] = `"1"`; exports[`fixtures > import-map > stdout 1`] = `"{ alias: 'alias' }"`; diff --git a/test/fixtures/deps/config.ts b/test/fixtures/deps/config.ts new file mode 100644 index 00000000..0ce65d7b --- /dev/null +++ b/test/fixtures/deps/config.ts @@ -0,0 +1,2 @@ +// https://github.com/unjs/jiti/issues/56 +console.log("npm:config:", "getFilesOrder" in require("config/parser")); diff --git a/test/fixtures/deps/consola.ts b/test/fixtures/deps/consola.ts new file mode 100644 index 00000000..332ef8f4 --- /dev/null +++ b/test/fixtures/deps/consola.ts @@ -0,0 +1,3 @@ +import consola from "consola"; + +consola.log("npm:consola:", true); diff --git a/test/fixtures/deps/etag.ts b/test/fixtures/deps/etag.ts new file mode 100644 index 00000000..9b1b2b32 --- /dev/null +++ b/test/fixtures/deps/etag.ts @@ -0,0 +1,7 @@ +// @ts-ignore +import etag from "etag"; + +console.log( + "npm:etag:", + etag("hello world") === `"b-Kq5sNclPz7QV2+lfQIuc6R7oRu0"`, +); diff --git a/test/fixtures/deps/index.ts b/test/fixtures/deps/index.ts new file mode 100644 index 00000000..27896c0f --- /dev/null +++ b/test/fixtures/deps/index.ts @@ -0,0 +1,6 @@ +import "./config"; +import "./consola"; +import "./etag"; +import "./mime"; +import "./typescript"; +import "./moment"; diff --git a/test/fixtures/deps/mime.ts b/test/fixtures/deps/mime.ts new file mode 100644 index 00000000..2d8555aa --- /dev/null +++ b/test/fixtures/deps/mime.ts @@ -0,0 +1,3 @@ +import mime from "mime"; + +console.log("npm:mime:", mime.getType("txt") === "text/plain"); diff --git a/test/fixtures/deps/moment.ts b/test/fixtures/deps/moment.ts new file mode 100644 index 00000000..e9d5563b --- /dev/null +++ b/test/fixtures/deps/moment.ts @@ -0,0 +1,8 @@ +import momentTZ from "moment-timezone"; + +console.log( + "npm:moment-timezone", + // https://www.npmjs.com/package/moment-timezone + momentTZ("2014-06-01T12:00:00Z").tz("America/Los_Angeles").format("ha z") === + "5am PDT", +); diff --git a/test/fixtures/deps/typescript.ts b/test/fixtures/deps/typescript.ts new file mode 100644 index 00000000..dc37d070 --- /dev/null +++ b/test/fixtures/deps/typescript.ts @@ -0,0 +1,3 @@ +import * as ts from "typescript"; + +console.log("npm:typescript:", "mapEntries" in ts); diff --git a/test/fixtures/exotic/index.ts b/test/fixtures/exotic/index.ts deleted file mode 100644 index 4ef7b785..00000000 --- a/test/fixtures/exotic/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import * as ts from "typescript"; - -console.log("Typescript:", "mapEntries" in ts); - -// https://github.com/unjs/jiti/issues/56 -console.log("Config:", "getFilesOrder" in require("config/parser")); diff --git a/test/native/deno.test.ts b/test/native/deno.test.ts index 1b0b5a38..742e6cc8 100644 --- a/test/native/deno.test.ts +++ b/test/native/deno.test.ts @@ -19,7 +19,7 @@ const ignore = new Set( "env", "typescript", "top-level-await", - "exotic", + "deps", "circular", "data-uri", "import-map", diff --git a/test/native/node.test.ts b/test/native/node.test.ts index cbd254b0..947546e0 100644 --- a/test/native/node.test.ts +++ b/test/native/node.test.ts @@ -19,7 +19,7 @@ const ignore = new Set( "env", "typescript", "top-level-await", - "exotic", + "deps", "circular", "data-uri", "jsx",