Repository navigation
Expand file tree
/
Copy pathimplicit-icons-to-explicit-imports.ts
More file actions
67 lines (58 loc) · 1.85 KB
/
Copy pathimplicit-icons-to-explicit-imports.ts
File metadata and controls
67 lines (58 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { defineTest } from "jscodeshift/dist/testUtils";
import { TransformOptions } from "../implicit-icons-to-explicit-imports";
// List of all test fixtures with an input and output pair for each.
const TEST_FIXTURES = [
"array",
"basic",
"custom-component-and-prop",
"dot-notation",
"duplicate-names-from-multiple-packages",
"existing-import",
"multiple-props",
"pro-array",
"pro-duplicate-names-from-multiple-packages"
] as const;
type TestFixtures = typeof TEST_FIXTURES[number];
type TestFixtureOptions = { [Test in TestFixtures]?: TransformOptions };
// All options are optional, but some of the fixtures require specific options.
const TEST_FIXTURE_OPTIONS: TestFixtureOptions = {
"custom-component-and-prop": {
componentName: "Button",
propName: "iconProp"
},
"dot-notation": { componentName: "Dot.Notation" },
"pro-array": { type: "pro" },
"pro-duplicate-names-from-multiple-packages": { type: "pro" }
};
describe("implicit-icons-to-explicit-imports", () => {
TEST_FIXTURES.forEach(test =>
defineTest(
__dirname,
"implicit-icons-to-explicit-imports",
TEST_FIXTURE_OPTIONS[test],
`implicit-icons-to-explicit-imports/${test}`,
{ parser: "tsx" }
)
);
describe("icons with variables", () => {
let spy: jest.SpyInstance;
beforeEach(() => {
spy = jest.spyOn(console, "error").mockImplementation();
});
afterEach(() => {
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenLastCalledWith(
expect.stringContaining(
`expected: icon={[StringLiteral, StringLiteral]}\nreceived: icon={[StringLiteral, Identifier]}\nManually update:`
)
);
});
defineTest(
__dirname,
"implicit-icons-to-explicit-imports",
null,
`implicit-icons-to-explicit-imports/variables`,
{ parser: "tsx" }
);
});
});