@@ -136,4 +136,101 @@ function Component() {
136136 const result = runMutation ( input ) ;
137137 expect ( result ) . toBe ( input ) ;
138138 } ) ;
139+
140+ it ( "should handle default import React and use React.Fragment" , ( ) => {
141+ const input = `
142+ import React from "react";
143+
144+ function Component() {
145+ return <></>;
146+ }
147+ ` . trim ( ) ;
148+
149+ const expected = `
150+ import React from "react";
151+ function Component() {
152+ return <React.Fragment></React.Fragment>;
153+ }
154+ ` . trim ( ) ;
155+ const result = runMutation ( input ) ;
156+ expect ( result ) . toBe ( expected ) ;
157+ } ) ;
158+
159+ it ( "should handle import * as React and use React.Fragment" , ( ) => {
160+ const input = `
161+ import * as React from "react";
162+
163+ function Component() {
164+ return <></>;
165+ }
166+ ` . trim ( ) ;
167+
168+ const expected = `
169+ import * as React from "react";
170+ function Component() {
171+ return <React.Fragment></React.Fragment>;
172+ }
173+ ` . trim ( ) ;
174+ const result = runMutation ( input ) ;
175+ expect ( result ) . toBe ( expected ) ;
176+ } ) ;
177+
178+ it ( "should handle mixed default and named imports" , ( ) => {
179+ const input = `
180+ import React, { useState } from "react";
181+
182+ function Component() {
183+ return <></>;
184+ }
185+ ` . trim ( ) ;
186+
187+ const expected = `
188+ import React, { useState } from "react";
189+ function Component() {
190+ return <React.Fragment></React.Fragment>;
191+ }
192+ ` . trim ( ) ;
193+ const result = runMutation ( input ) ;
194+ expect ( result ) . toBe ( expected ) ;
195+ } ) ;
196+
197+ it ( "should handle separate namespace and named imports" , ( ) => {
198+ const input = `
199+ import * as React from "react";
200+ import { Fragment } from "react";
201+
202+ function Component() {
203+ return <></>;
204+ }
205+ ` . trim ( ) ;
206+
207+ const expected = `
208+ import * as React from "react";
209+ import { Fragment } from "react";
210+ function Component() {
211+ return <Fragment></Fragment>;
212+ }
213+ ` . trim ( ) ;
214+ const result = runMutation ( input ) ;
215+ expect ( result ) . toBe ( expected ) ;
216+ } ) ;
217+
218+ it ( "should handle import * as SomeOtherName from react" , ( ) => {
219+ const input = `
220+ import * as SomeOtherName from "react";
221+
222+ function Component() {
223+ return <></>;
224+ }
225+ ` . trim ( ) ;
226+
227+ const expected = `
228+ import * as SomeOtherName from "react";
229+ function Component() {
230+ return <SomeOtherName.Fragment></SomeOtherName.Fragment>;
231+ }
232+ ` . trim ( ) ;
233+ const result = runMutation ( input ) ;
234+ expect ( result ) . toBe ( expected ) ;
235+ } ) ;
139236} ) ;
0 commit comments