Skip to content

Commit 42acf71

Browse files
committed
test(rollup): entry
1 parent 55ddc6f commit 42acf71

File tree

10 files changed

+75
-0
lines changed

10 files changed

+75
-0
lines changed

test/rollup/entry/jest-ignore/src/__test__/bar.ts

Whitespace-only changes.

test/rollup/entry/jest-ignore/src/bar.js

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const bar = "bar";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

test/rollup/entry/jest-ignore/src/dir2/bar/index.ts

Whitespace-only changes.

test/rollup/entry/jest-ignore/src/dir2/index.jsx

Whitespace-only changes.

test/rollup/entry/jest-ignore/src/dir3/index.js

Whitespace-only changes.

test/rollup/entry/jest-ignore/src/dir4/bar/index.ts

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

test/rollup/entry/test.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import * as path from "path";
2+
import {
3+
getEntryFiles,
4+
DEFAULT_PATTERNS,
5+
DEFAULT_PATTERNS_EXT,
6+
} from "../../../src/rollup/entry";
7+
8+
const baseDir = path.join(__dirname, "jest-ignore/src");
9+
10+
const PATTERNS_SUB_DIR = [
11+
...DEFAULT_PATTERNS,
12+
`./*/*.{${DEFAULT_PATTERNS_EXT}}`,
13+
`./*/*/index.{${DEFAULT_PATTERNS_EXT}}`,
14+
];
15+
16+
test("get entries with index files auto trimmed", async () => {
17+
const input = await getEntryFiles({ baseDir });
18+
19+
expect(input).toStrictEqual({
20+
dir1: "dir1/index.ts",
21+
dir2: "dir2/index.jsx",
22+
dir3: "dir3/index.js",
23+
bar: "bar.js",
24+
index: "index.ts",
25+
});
26+
});
27+
28+
test("get entries with index files auto trimmed (sub dir)", async () => {
29+
const input = await getEntryFiles({ baseDir, patterns: PATTERNS_SUB_DIR });
30+
31+
expect(input).toStrictEqual({
32+
"dir1/index": "dir1/index.ts",
33+
"dir1/bar": "dir1/bar.ts",
34+
"dir2/index": "dir2/index.jsx",
35+
"dir2/bar": "dir2/bar/index.ts",
36+
dir3: "dir3/index.js",
37+
"dir4/bar": "dir4/bar/index.ts",
38+
bar: "bar.js",
39+
index: "index.ts",
40+
});
41+
});
42+
43+
test("get entries with index files kept", async () => {
44+
const input = await getEntryFiles({ baseDir, keepIndexFiles: true });
45+
46+
expect(input).toStrictEqual({
47+
"dir1/index": "dir1/index.ts",
48+
"dir2/index": "dir2/index.jsx",
49+
"dir3/index": "dir3/index.js",
50+
bar: "bar.js",
51+
index: "index.ts",
52+
});
53+
});
54+
55+
test("get entries with index files kept (sub dir)", async () => {
56+
const input = await getEntryFiles({
57+
baseDir,
58+
patterns: PATTERNS_SUB_DIR,
59+
keepIndexFiles: true,
60+
});
61+
62+
expect(input).toStrictEqual({
63+
"dir1/index": "dir1/index.ts",
64+
"dir1/bar": "dir1/bar.ts",
65+
"dir2/index": "dir2/index.jsx",
66+
"dir2/bar/index": "dir2/bar/index.ts",
67+
"dir3/index": "dir3/index.js",
68+
"dir4/bar/index": "dir4/bar/index.ts",
69+
bar: "bar.js",
70+
index: "index.ts",
71+
});
72+
});

0 commit comments

Comments
 (0)