@@ -35,31 +35,21 @@ describe("plugin-completions/commands", () => {
3535 } ) ;
3636
3737 it ( "should throw error if shell is missing" , async ( ) => {
38- const cli = TestBaseCli ( ) . use ( completionsPlugin ( ) ) ;
39- const errorFn = vi . fn ( ) ;
40- cli . errorHandler ( errorFn ) ;
41-
42- await cli . parse ( [ "completions" , "install" ] ) ;
43-
44- await new Promise ( ( resolve ) => setTimeout ( resolve , 10 ) ) ;
45-
46- expect ( errorFn ) . toHaveBeenCalled ( ) ;
47- expect ( errorFn . mock . calls [ 0 ] [ 0 ] . message ) . toContain (
48- "Please specify the shell type" ,
49- ) ;
38+ await expect ( async ( ) => {
39+ await TestBaseCli ( )
40+ . use ( completionsPlugin ( ) )
41+ . parse ( [ "completions" , "install" ] ) ;
42+ } ) . rejects . toThrow ( "Please specify the shell type" ) ;
5043 } ) ;
5144
5245 it ( "should throw error if shell is unsupported" , async ( ) => {
53- const cli = TestBaseCli ( ) . use ( completionsPlugin ( ) ) ;
54- const errorFn = vi . fn ( ) ;
55- cli . errorHandler ( errorFn ) ;
56-
57- await cli . parse ( [ "completions" , "install" , "--shell" , "invalid" ] ) ;
58-
59- await new Promise ( ( resolve ) => setTimeout ( resolve , 10 ) ) ;
60-
61- expect ( errorFn ) . toHaveBeenCalled ( ) ;
62- expect ( errorFn . mock . calls [ 0 ] [ 0 ] . message ) . toContain ( "Unsupported shell" ) ;
46+ await expect ( async ( ) => {
47+ await TestBaseCli ( )
48+ . use ( completionsPlugin ( ) )
49+ . parse ( [ "completions" , "install" , "--shell" , "invalid" ] ) ;
50+ } ) . rejects . toThrowErrorMatchingInlineSnapshot (
51+ "[Error: Invalid value: invalid. Must be one of: bash, zsh, fish]" ,
52+ ) ;
6353 } ) ;
6454 } ) ;
6555
@@ -93,31 +83,19 @@ describe("plugin-completions/commands", () => {
9383 } ) ;
9484
9585 it ( "should throw error if shell is missing" , async ( ) => {
96- const cli = TestBaseCli ( ) . use ( completionsPlugin ( ) ) ;
97- const errorFn = vi . fn ( ) ;
98- cli . errorHandler ( errorFn ) ;
99-
100- await cli . parse ( [ "completions" ] ) ;
101-
102- await new Promise ( ( resolve ) => setTimeout ( resolve , 10 ) ) ;
103-
104- expect ( errorFn ) . toHaveBeenCalled ( ) ;
105- expect ( errorFn . mock . calls [ 0 ] [ 0 ] . message ) . toContain (
106- "Please specify the shell type" ,
107- ) ;
86+ await expect ( async ( ) => {
87+ await TestBaseCli ( ) . use ( completionsPlugin ( ) ) . parse ( [ "completions" ] ) ;
88+ } ) . rejects . toThrow ( "Please specify the shell type" ) ;
10889 } ) ;
10990
11091 it ( "should throw error if shell is unsupported" , async ( ) => {
111- const cli = TestBaseCli ( ) . use ( completionsPlugin ( ) ) ;
112- const errorFn = vi . fn ( ) ;
113- cli . errorHandler ( errorFn ) ;
114-
115- await cli . parse ( [ "completions" , "--shell" , "invalid" ] ) ;
116-
117- await new Promise ( ( resolve ) => setTimeout ( resolve , 10 ) ) ;
118-
119- expect ( errorFn ) . toHaveBeenCalled ( ) ;
120- expect ( errorFn . mock . calls [ 0 ] [ 0 ] . message ) . toContain ( "Unsupported shell" ) ;
92+ await expect ( async ( ) => {
93+ await TestBaseCli ( )
94+ . use ( completionsPlugin ( ) )
95+ . parse ( [ "completions" , "--shell" , "invalid" ] ) ;
96+ } ) . rejects . toThrowErrorMatchingInlineSnapshot (
97+ "[Error: Invalid value: invalid. Must be one of: bash, zsh, fish]" ,
98+ ) ;
12199 } ) ;
122100 } ) ;
123101
0 commit comments