Skip to content

Commit

Permalink
test: add dependency tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 2, 2024
1 parent f99a1d7 commit 1d86ca3
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 13 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
37 changes: 37 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions test/__snapshots__/fixtures.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' }"`;
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/deps/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// https://github.com/unjs/jiti/issues/56
console.log("npm:config:", "getFilesOrder" in require("config/parser"));
3 changes: 3 additions & 0 deletions test/fixtures/deps/consola.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import consola from "consola";

consola.log("npm:consola:", true);
7 changes: 7 additions & 0 deletions test/fixtures/deps/etag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @ts-ignore
import etag from "etag";

console.log(
"npm:etag:",
etag("hello world") === `"b-Kq5sNclPz7QV2+lfQIuc6R7oRu0"`,
);
6 changes: 6 additions & 0 deletions test/fixtures/deps/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "./config";
import "./consola";
import "./etag";
import "./mime";
import "./typescript";
import "./moment";
3 changes: 3 additions & 0 deletions test/fixtures/deps/mime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import mime from "mime";

console.log("npm:mime:", mime.getType("txt") === "text/plain");
8 changes: 8 additions & 0 deletions test/fixtures/deps/moment.ts
Original file line number Diff line number Diff line change
@@ -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",
);
3 changes: 3 additions & 0 deletions test/fixtures/deps/typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as ts from "typescript";

console.log("npm:typescript:", "mapEntries" in ts);
6 changes: 0 additions & 6 deletions test/fixtures/exotic/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion test/native/deno.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ignore = new Set(
"env",
"typescript",
"top-level-await",
"exotic",
"deps",
"circular",
"data-uri",
"import-map",
Expand Down
2 changes: 1 addition & 1 deletion test/native/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ignore = new Set(
"env",
"typescript",
"top-level-await",
"exotic",
"deps",
"circular",
"data-uri",
"jsx",
Expand Down

0 comments on commit 1d86ca3

Please sign in to comment.