@@ -129,7 +129,7 @@ func a =
129129 ) ;
130130 } ) ;
131131
132- it ( "should prefix branch variant if needed " , async ( ) => {
132+ it ( "should prefix branch variant if other branches are prefixed " , async ( ) => {
133133 const source = `
134134--@ Foo.elm
135135module Foo exposing (..)
@@ -182,4 +182,142 @@ test response =
182182 expectedSource ,
183183 ) ;
184184 } ) ;
185+
186+ it ( "should prefix case if other cases are prefixed 2" , async ( ) => {
187+ const source = `
188+ --@ Foo.elm
189+ module Foo exposing (..)
190+
191+ type Foo
192+ = Bar
193+ | Biz
194+
195+ --@ Test.elm
196+ module Test exposing (..)
197+
198+ import Foo
199+
200+ test : Foo -> Html.Html msg
201+ test response =
202+ case response of
203+ --^
204+ Foo.Bar ->
205+ Html.text "x"
206+ ` ;
207+
208+ const expectedSource = `
209+ --@ Foo.elm
210+ module Foo exposing (..)
211+
212+ type Foo
213+ = Bar
214+ | Biz
215+
216+ --@ Test.elm
217+ module Test exposing (..)
218+
219+ import Foo
220+
221+ test : Foo -> Html.Html msg
222+ test response =
223+ case response of
224+ Foo.Bar ->
225+ Html.text "x"
226+
227+ Foo.Biz ->
228+ Debug.todo "branch 'Foo.Biz' not implemented"
229+ ` ;
230+
231+ await testCodeAction (
232+ source ,
233+ [ { title : "Add missing case branches" } ] ,
234+ expectedSource ,
235+ ) ;
236+ } ) ;
237+
238+ it ( "should not prefix case if other cases are not prefixed" , async ( ) => {
239+ const source = `
240+ --@ Test.elm
241+ module Test exposing (..)
242+
243+ type Foo
244+ = Bar
245+ | Biz
246+
247+ test : Foo -> ()
248+ test response =
249+ case response of
250+ --^
251+ Bar ->
252+ ()
253+
254+ ` ;
255+
256+ const expectedSource = `
257+ --@ Test.elm
258+ module Test exposing (..)
259+
260+ type Foo
261+ = Bar
262+ | Biz
263+
264+ test : Foo -> ()
265+ test response =
266+ case response of
267+ Bar ->
268+ ()
269+
270+ Biz ->
271+ Debug.todo "branch 'Biz' not implemented"
272+
273+ ` ;
274+
275+ await testCodeAction (
276+ source ,
277+ [ { title : "Add missing case branches" } ] ,
278+ expectedSource ,
279+ ) ;
280+ } ) ;
281+
282+ it ( "should not prefix case if other cases are not prefixed 2" , async ( ) => {
283+ const source = `
284+ --@ Test.elm
285+ module Test exposing (..)
286+
287+ type Foo
288+ = Bar
289+ | Biz
290+
291+ test : Foo -> Html.Html msg
292+ test response =
293+ case response of
294+ --^
295+ Bar ->
296+ Html.text "x"
297+ ` ;
298+
299+ const expectedSource = `
300+ --@ Test.elm
301+ module Test exposing (..)
302+
303+ type Foo
304+ = Bar
305+ | Biz
306+
307+ test : Foo -> Html.Html msg
308+ test response =
309+ case response of
310+ Bar ->
311+ Html.text "x"
312+
313+ Biz ->
314+ Debug.todo "branch 'Biz' not implemented"
315+ ` ;
316+
317+ await testCodeAction (
318+ source ,
319+ [ { title : "Add missing case branches" } ] ,
320+ expectedSource ,
321+ ) ;
322+ } ) ;
185323} ) ;
0 commit comments