@@ -146,6 +146,49 @@ const generateValidCases = (
146146 ` ,
147147 `expect(${ thing } ).not.${ matcher } ()` ,
148148 `expect("hello" as ${ thing } ).${ matcher } ();` ,
149+ dedent `
150+ declare function mx(): Promise<string | ${ thing } >;
151+
152+ it('is async', async () => {
153+ await expect(mx()).resolves.${ matcher } ();
154+ });
155+ ` ,
156+ dedent `
157+ declare function mx(): Promise<string | ${ thing } >;
158+
159+ it('is async', async () => {
160+ await expect(mx()).rejects.${ matcher } ();
161+ });
162+ ` ,
163+ dedent `
164+ declare function mx(): Promise<string | ${ thing } >;
165+
166+ it('is async', async () => {
167+ await expect(mx()).rejects.not.${ matcher } ();
168+ });
169+ ` ,
170+ dedent `
171+ declare function mx(): Promise<string | ${ thing } >;
172+
173+ it('is async', async () => {
174+ expect(await mx()).not.${ matcher } ();
175+ });
176+ ` ,
177+ // todo: ideally we should be able to catch these
178+ dedent `
179+ declare function mx(): Promise<string>;
180+
181+ it('is async', async () => {
182+ await expect(mx()).resolves.${ matcher } ();
183+ });
184+ ` ,
185+ dedent `
186+ declare function mx(): Promise<string>;
187+
188+ it('is async', async () => {
189+ await expect(mx()).rejects.not.${ matcher } ();
190+ });
191+ ` ,
149192 ] ;
150193} ;
151194
@@ -298,6 +341,41 @@ const generateInvalidCases = (
298341 ] ,
299342 } ,
300343
344+ {
345+ code : dedent `
346+ declare function mx(): Promise<string>;
347+
348+ it('is async', async () => {
349+ expect(await mx()).${ matcher } ();
350+ });
351+ ` ,
352+ errors : [
353+ {
354+ messageId : 'unnecessaryAssertion' ,
355+ data : { thing } ,
356+ line : 4 ,
357+ } ,
358+ ] ,
359+ } ,
360+
361+ // todo: ideally we should support promises
362+ // {
363+ // code: dedent`
364+ // declare function mx(): Promise<string>;
365+ //
366+ // it('is async', async () => {
367+ // await expect(mx()).resolves.${matcher}();
368+ // });
369+ // `,
370+ // errors: [
371+ // {
372+ // messageId: 'unnecessaryAssertion',
373+ // data: { thing },
374+ // line: 3,
375+ // },
376+ // ],
377+ // },
378+
301379 // todo: ideally support these
302380 // {
303381 // code: dedent`
0 commit comments