Skip to content

Commit d1fabf3

Browse files
committed
test Array generic
1 parent 5080e22 commit d1fabf3

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

transforms/__tests__/deprecated-react-child.js

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function applyTransform(source, options = {}) {
1010
{
1111
path: "test.d.ts",
1212
source: dedent(source),
13-
},
13+
}
1414
);
1515
}
1616

@@ -21,7 +21,7 @@ test("not modified", () => {
2121
interface Props {
2222
children?: ReactNode;
2323
}
24-
`),
24+
`)
2525
).toMatchInlineSnapshot(`
2626
"import * as React from 'react';
2727
interface Props {
@@ -37,7 +37,7 @@ test("named import", () => {
3737
interface Props {
3838
children?: ReactChild;
3939
}
40-
`),
40+
`)
4141
).toMatchInlineSnapshot(`
4242
"import { ReactElement } from 'react';
4343
interface Props {
@@ -53,7 +53,7 @@ test("named type import", () => {
5353
interface Props {
5454
children?: ReactChild;
5555
}
56-
`),
56+
`)
5757
).toMatchInlineSnapshot(`
5858
"import { type ReactElement } from 'react';
5959
interface Props {
@@ -69,7 +69,7 @@ test("named type import with existing target import", () => {
6969
interface Props {
7070
children?: ReactChild;
7171
}
72-
`),
72+
`)
7373
).toMatchInlineSnapshot(`
7474
"import { ReactElement } from 'react';
7575
interface Props {
@@ -85,7 +85,7 @@ test("false-negative named renamed import", () => {
8585
interface Props {
8686
children?: MyReactChild;
8787
}
88-
`),
88+
`)
8989
).toMatchInlineSnapshot(`
9090
"import { ReactChild as MyReactChild } from 'react';
9191
interface Props {
@@ -101,7 +101,7 @@ test("namespace import", () => {
101101
interface Props {
102102
children?: React.ReactChild;
103103
}
104-
`),
104+
`)
105105
).toMatchInlineSnapshot(`
106106
"import * as React from 'react';
107107
interface Props {
@@ -115,25 +115,41 @@ test("as type parameter", () => {
115115
applyTransform(`
116116
import * as React from 'react';
117117
createAction<React.ReactChild>()
118-
`),
118+
`)
119119
).toMatchInlineSnapshot(`
120120
"import * as React from 'react';
121121
createAction<React.ReactElement | number | string>()"
122122
`);
123123
});
124124

125-
test("array syntax", () => {
125+
test("array type syntax", () => {
126126
expect(
127127
applyTransform(`
128-
import { ReactChild } from 'react';
129-
interface Props {
128+
import { ReactChild } from 'react';
129+
interface Props {
130130
children?: ReactChild[];
131131
}
132-
`),
132+
`)
133133
).toMatchInlineSnapshot(`
134134
"import { ReactElement } from 'react';
135135
interface Props {
136-
children?: (ReactElement | number | string)[];
137-
}"
136+
children?: (ReactElement | number | string)[];
137+
}"
138+
`);
139+
});
140+
141+
test("Array generic", () => {
142+
expect(
143+
applyTransform(`
144+
import { ReactChild } from 'react';
145+
interface Props {
146+
children?: Array<ReactChild>;
147+
}
148+
`)
149+
).toMatchInlineSnapshot(`
150+
"import { ReactElement } from 'react';
151+
interface Props {
152+
children?: Array<ReactElement | number | string>;
153+
}"
138154
`);
139155
});

0 commit comments

Comments
 (0)