|
1 | | -module.exports = jest.fn(function mockGlob(globString, options, callback) { |
| 1 | +const glob = jest.fn(async function mockGlob(globString) { |
2 | 2 | /* eslint complexity:0 */ |
3 | 3 | if (globString.includes('1')) { |
4 | | - callback(null, [ |
| 4 | + return [ |
5 | 5 | fredProject('index.js'), |
6 | 6 | fredProject('start.js'), |
7 | 7 | fredProject('stop/index.js'), |
8 | 8 | fredProject('stop/log.js') |
9 | | - ]); |
10 | | - } else if (globString.includes('2')) { |
11 | | - callback(null, [ |
| 9 | + ]; |
| 10 | + } |
| 11 | + |
| 12 | + if (globString.includes('2')) { |
| 13 | + return [ |
12 | 14 | fredProject('index.js'), |
13 | 15 | fredProject('start.js'), |
14 | 16 | fredProject('continue/index.js'), |
15 | 17 | fredProject('continue/forever.js') |
16 | | - ]); |
17 | | - } else if (globString.includes('node_modules')) { |
18 | | - callback(null, [ |
| 18 | + ]; |
| 19 | + } |
| 20 | + |
| 21 | + if (globString.includes('node_modules')) { |
| 22 | + return [ |
19 | 23 | fredProject('foo/node_modules/stuff1.js'), |
20 | 24 | fredProject('foo/node_modules/stuff2.js'), |
21 | 25 | fredProject('foo/node_modules/stuff3.js') |
22 | | - ]); |
23 | | - } else if (globString.includes('files-with-syntax-errors')) { |
24 | | - callback(null, [ |
25 | | - fredProject('syntax-error1.js'), |
26 | | - fredProject('syntax-error2.js') |
27 | | - ]); |
28 | | - } else if (globString.includes('no-match')) { |
29 | | - callback(null, []); |
30 | | - } else if (globString.includes('throw-error')) { |
31 | | - callback(new Error('something weird happened')); |
32 | | - } else if (globString.includes('no-change')) { |
33 | | - callback(null, [ |
| 26 | + ]; |
| 27 | + } |
| 28 | + |
| 29 | + if (globString.includes('files-with-syntax-errors')) { |
| 30 | + return [fredProject('syntax-error1.js'), fredProject('syntax-error2.js')]; |
| 31 | + } |
| 32 | + |
| 33 | + if (globString.includes('no-match')) { |
| 34 | + return []; |
| 35 | + } |
| 36 | + |
| 37 | + if (globString.includes('throw-error')) { |
| 38 | + throw new Error('something weird happened'); |
| 39 | + } |
| 40 | + |
| 41 | + if (globString.includes('no-change')) { |
| 42 | + return [ |
34 | 43 | fredProject('no-change/1.js'), |
35 | 44 | fredProject('no-change/2.js'), |
36 | 45 | fredProject('no-change/3.js') |
37 | | - ]); |
38 | | - } else if (globString.includes('eslintignored')) { |
39 | | - callback(null, [ |
| 46 | + ]; |
| 47 | + } |
| 48 | + |
| 49 | + if (globString.includes('eslintignored')) { |
| 50 | + return [ |
40 | 51 | fredProject('eslintignored1.js'), |
41 | 52 | fredProject('eslintignored2.js'), |
42 | 53 | fredProject('eslintignored3.js'), |
43 | 54 | fredProject('applied4.js') |
44 | | - ]); |
45 | | - } else if (globString.includes('prettierignored')) { |
46 | | - callback(null, [ |
| 55 | + ]; |
| 56 | + } |
| 57 | + |
| 58 | + if (globString.includes('prettierignored')) { |
| 59 | + return [ |
47 | 60 | fredProject('prettierignored1.js'), |
48 | 61 | fredProject('prettierignored2.js'), |
49 | 62 | fredProject('prettierignored3.js'), |
50 | 63 | fredProject('applied4.js') |
51 | | - ]); |
52 | | - } else if (globString.includes('no-ignore')) { |
53 | | - callback(null, [ |
| 64 | + ]; |
| 65 | + } |
| 66 | + |
| 67 | + if (globString.includes('no-ignore')) { |
| 68 | + return [ |
54 | 69 | barneyProject('no-ignore/1.js'), |
55 | 70 | barneyProject('no-ignore/2.js'), |
56 | 71 | barneyProject('no-ignore/3.js') |
57 | | - ]); |
58 | | - } else if (globString.includes('eslint-config-error')) { |
59 | | - callback(null, [ |
| 72 | + ]; |
| 73 | + } |
| 74 | + |
| 75 | + if (globString.includes('eslint-config-error')) { |
| 76 | + return [ |
60 | 77 | fredProject('eslint-config-error/1.js'), |
61 | 78 | fredProject('eslint-config-error/2.js') |
62 | | - ]); |
63 | | - } else { |
64 | | - throw new Error( |
65 | | - `Your test globString: "${globString}"` + |
66 | | - " doesn't have associated mock data." |
67 | | - ); |
| 79 | + ]; |
68 | 80 | } |
| 81 | + |
| 82 | + throw new Error( |
| 83 | + `Your test globString: "${globString}"` + |
| 84 | + " doesn't have associated mock data." |
| 85 | + ); |
69 | 86 | }); |
70 | 87 |
|
| 88 | +glob.glob = glob; |
| 89 | + |
| 90 | +exports.glob = glob; |
| 91 | + |
71 | 92 | function fredProject(path) { |
72 | 93 | return `/Users/fredFlintstone/Developer/top-secret/footless-carriage/${path}`; |
73 | 94 | } |
|
0 commit comments