@@ -5,7 +5,73 @@ import { FlatCompatRuleTester as RuleTester } from './test-utils';
5
5
new RuleTester ( {
6
6
parser : require . resolve ( '@typescript-eslint/parser' ) ,
7
7
} ) . run ( 'prefer-importing-jest-globals: typescript edition' , rule , {
8
- valid : [ ] ,
8
+ valid : [
9
+ {
10
+ code : dedent `
11
+ // with import
12
+ import { test, expect } from '@jest/globals';
13
+ test('should pass', () => {
14
+ expect(true).toBeDefined();
15
+ });
16
+ ` ,
17
+ parserOptions : { sourceType : 'module' } ,
18
+ } ,
19
+ {
20
+ code : dedent `
21
+ test('should pass', () => {
22
+ expect(true).toBeDefined();
23
+ });
24
+ ` ,
25
+ options : [ { types : [ 'jest' ] } ] ,
26
+ parserOptions : { sourceType : 'module' } ,
27
+ } ,
28
+ {
29
+ code : dedent `
30
+ const { it } = require('@jest/globals');
31
+ it('should pass', () => {
32
+ expect(true).toBeDefined();
33
+ });
34
+ ` ,
35
+ options : [ { types : [ 'test' ] } ] ,
36
+ parserOptions : { sourceType : 'module' } ,
37
+ } ,
38
+ {
39
+ code : dedent `
40
+ // with require
41
+ const { test, expect } = require('@jest/globals');
42
+ test('should pass', () => {
43
+ expect(true).toBeDefined();
44
+ });
45
+ ` ,
46
+ } ,
47
+ {
48
+ code : dedent `
49
+ const { test, expect } = require(\`@jest/globals\`);
50
+ test('should pass', () => {
51
+ expect(true).toBeDefined();
52
+ });
53
+ ` ,
54
+ } ,
55
+ {
56
+ code : dedent `
57
+ import { it as itChecks } from '@jest/globals';
58
+ itChecks("foo");
59
+ ` ,
60
+ parserOptions : { sourceType : 'module' } ,
61
+ } ,
62
+ {
63
+ code : dedent `
64
+ const { test } = require('@jest/globals');
65
+ test("foo");
66
+ ` ,
67
+ } ,
68
+ {
69
+ code : dedent `
70
+ const { test } = require('my-test-library');
71
+ test("foo");
72
+ ` ,
73
+ } ,
74
+ ] ,
9
75
invalid : [
10
76
{
11
77
code : dedent `
0 commit comments