@@ -158,4 +158,298 @@ ASP.NET Core gRPC Service grpc [C#]
158158 }
159159 } ) ;
160160 } ) ;
161+
162+ describe ( 'format' , ( ) => {
163+ it ( 'should call subcommands properly when on .NET 6 and passing --fixWhitespace' , ( ) => {
164+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '6.0.0' ) ) ;
165+ const spy = jest
166+ . spyOn ( dotnetClient , 'logAndExecute' )
167+ . mockImplementation ( ( ) => ( { } ) ) ;
168+ dotnetClient . format ( 'my-project' , {
169+ fixWhitespace : false ,
170+ } ) ;
171+ expect ( spy ) . toHaveBeenCalledTimes ( 2 ) ;
172+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
173+ Array [
174+ Array [
175+ Array [
176+ "format",
177+ "style",
178+ "my-project",
179+ ],
180+ ],
181+ Array [
182+ Array [
183+ "format",
184+ "analyzers",
185+ "my-project",
186+ ],
187+ ],
188+ ]
189+ ` ) ;
190+ } ) ;
191+
192+ it ( 'should call subcommands properly when on .NET 6 and passing --fixAnalyzers' , ( ) => {
193+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '6.0.0' ) ) ;
194+ const spy = jest
195+ . spyOn ( dotnetClient , 'logAndExecute' )
196+ . mockImplementation ( ( ) => ( { } ) ) ;
197+ dotnetClient . format ( 'my-project' , {
198+ fixAnalyzers : false ,
199+ } ) ;
200+ expect ( spy ) . toHaveBeenCalledTimes ( 2 ) ;
201+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
202+ Array [
203+ Array [
204+ Array [
205+ "format",
206+ "whitespace",
207+ "my-project",
208+ ],
209+ ],
210+ Array [
211+ Array [
212+ "format",
213+ "style",
214+ "my-project",
215+ ],
216+ ],
217+ ]
218+ ` ) ;
219+ } ) ;
220+
221+ it ( 'should call subcommands properly when on .NET 6 and passing --fixAnalyzers severity' , ( ) => {
222+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '6.0.0' ) ) ;
223+ const spy = jest
224+ . spyOn ( dotnetClient , 'logAndExecute' )
225+ . mockImplementation ( ( ) => ( { } ) ) ;
226+ dotnetClient . format ( 'my-project' , {
227+ fixAnalyzers : 'warn' ,
228+ } ) ;
229+ expect ( spy ) . toHaveBeenCalledTimes ( 3 ) ;
230+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
231+ Array [
232+ Array [
233+ Array [
234+ "format",
235+ "whitespace",
236+ "my-project",
237+ ],
238+ ],
239+ Array [
240+ Array [
241+ "format",
242+ "style",
243+ "my-project",
244+ ],
245+ ],
246+ Array [
247+ Array [
248+ "format",
249+ "analyzers",
250+ "my-project",
251+ "--severity",
252+ "warn",
253+ ],
254+ ],
255+ ]
256+ ` ) ;
257+ } ) ;
258+
259+ it ( 'should call subcommands properly when on .NET 6 and passing --fixStyle' , ( ) => {
260+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '6.0.0' ) ) ;
261+ const spy = jest
262+ . spyOn ( dotnetClient , 'logAndExecute' )
263+ . mockImplementation ( ( ) => ( { } ) ) ;
264+ dotnetClient . format ( 'my-project' , {
265+ fixStyle : false ,
266+ } ) ;
267+ expect ( spy ) . toHaveBeenCalledTimes ( 2 ) ;
268+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
269+ Array [
270+ Array [
271+ Array [
272+ "format",
273+ "whitespace",
274+ "my-project",
275+ ],
276+ ],
277+ Array [
278+ Array [
279+ "format",
280+ "analyzers",
281+ "my-project",
282+ ],
283+ ],
284+ ]
285+ ` ) ;
286+ } ) ;
287+
288+ it ( 'should call subcommands properly when on .NET 6 and passing --fixAnalyzers severity' , ( ) => {
289+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '6.0.0' ) ) ;
290+ const spy = jest
291+ . spyOn ( dotnetClient , 'logAndExecute' )
292+ . mockImplementation ( ( ) => ( { } ) ) ;
293+ dotnetClient . format ( 'my-project' , {
294+ fixStyle : 'warn' ,
295+ } ) ;
296+ expect ( spy ) . toHaveBeenCalledTimes ( 3 ) ;
297+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
298+ Array [
299+ Array [
300+ Array [
301+ "format",
302+ "whitespace",
303+ "my-project",
304+ ],
305+ ],
306+ Array [
307+ Array [
308+ "format",
309+ "style",
310+ "my-project",
311+ "--severity",
312+ "warn",
313+ ],
314+ ],
315+ Array [
316+ Array [
317+ "format",
318+ "analyzers",
319+ "my-project",
320+ ],
321+ ],
322+ ]
323+ ` ) ;
324+ } ) ;
325+
326+ it ( 'should not pass `check` flag when on .NET 6' , ( ) => {
327+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '6.0.0' ) ) ;
328+ const spy = jest
329+ . spyOn ( dotnetClient , 'logAndExecute' )
330+ . mockImplementation ( ( ) => ( { } ) ) ;
331+ dotnetClient . format ( 'my-project' , {
332+ check : true ,
333+ } ) ;
334+ expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
335+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
336+ Array [
337+ Array [
338+ Array [
339+ "format",
340+ "my-project",
341+ "--verify-no-changes",
342+ ],
343+ ],
344+ ]
345+ ` ) ;
346+ } ) ;
347+
348+ it ( 'should call single command when on .NET 6 and not passing any options' , ( ) => {
349+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '6.0.0' ) ) ;
350+ const spy = jest
351+ . spyOn ( dotnetClient , 'logAndExecute' )
352+ . mockImplementation ( ( ) => ( { } ) ) ;
353+ dotnetClient . format ( 'my-project' ) ;
354+ expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
355+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
356+ Array [
357+ Array [
358+ Array [
359+ "format",
360+ "my-project",
361+ ],
362+ ],
363+ ]
364+ ` ) ;
365+ } ) ;
366+
367+ it ( 'should call single command when on .NET 5 and not passing any options' , ( ) => {
368+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '5.0.0' ) ) ;
369+ const spy = jest
370+ . spyOn ( dotnetClient , 'logAndExecute' )
371+ . mockImplementation ( ( ) => ( { } ) ) ;
372+ dotnetClient . format ( 'my-project' ) ;
373+ expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
374+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
375+ Array [
376+ Array [
377+ Array [
378+ "format",
379+ "my-project",
380+ ],
381+ ],
382+ ]
383+ ` ) ;
384+ } ) ;
385+
386+ it ( 'should call single command when on .NET 5 if passing --fixWhitespace' , ( ) => {
387+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '5.0.0' ) ) ;
388+ const spy = jest
389+ . spyOn ( dotnetClient , 'logAndExecute' )
390+ . mockImplementation ( ( ) => ( { } ) ) ;
391+ dotnetClient . format ( 'my-project' , {
392+ fixWhitespace : false ,
393+ } ) ;
394+ expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
395+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
396+ Array [
397+ Array [
398+ Array [
399+ "format",
400+ "my-project",
401+ "--fix-whitespace",
402+ "false",
403+ ],
404+ ],
405+ ]
406+ ` ) ;
407+ } ) ;
408+
409+ it ( 'should call single command when on .NET 5 if passing --fixStyle' , ( ) => {
410+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '5.0.0' ) ) ;
411+ const spy = jest
412+ . spyOn ( dotnetClient , 'logAndExecute' )
413+ . mockImplementation ( ( ) => ( { } ) ) ;
414+ dotnetClient . format ( 'my-project' , {
415+ fixStyle : false ,
416+ } ) ;
417+ expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
418+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
419+ Array [
420+ Array [
421+ Array [
422+ "format",
423+ "my-project",
424+ "--fix-style",
425+ "false",
426+ ],
427+ ],
428+ ]
429+ ` ) ;
430+ } ) ;
431+
432+ it ( 'should call single command when on .NET 5 if passing --fixAnalyzers' , ( ) => {
433+ const dotnetClient = new DotNetClient ( mockDotnetFactory ( '5.0.0' ) ) ;
434+ const spy = jest
435+ . spyOn ( dotnetClient , 'logAndExecute' )
436+ . mockImplementation ( ( ) => ( { } ) ) ;
437+ dotnetClient . format ( 'my-project' , {
438+ fixAnalyzers : false ,
439+ } ) ;
440+ expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
441+ expect ( spy . mock . calls ) . toMatchInlineSnapshot ( `
442+ Array [
443+ Array [
444+ Array [
445+ "format",
446+ "my-project",
447+ "--fix-analyzers",
448+ "false",
449+ ],
450+ ],
451+ ]
452+ ` ) ;
453+ } ) ;
454+ } ) ;
161455} ) ;
0 commit comments