|
1 | 1 | import pack from './utils/pack'; |
2 | 2 |
|
3 | 3 | describe('emit warning', () => { |
4 | | - it('should not emit warnings if emitWarning is false', (done) => { |
| 4 | + it('should not emit warnings if emitWarning is false', async () => { |
5 | 5 | const compiler = pack('warn', { emitWarning: false }); |
6 | 6 |
|
7 | | - compiler.run((err, stats) => { |
8 | | - expect(err).toBeNull(); |
9 | | - expect(stats.hasWarnings()).toBe(false); |
10 | | - done(); |
11 | | - }); |
| 7 | + const stats = await compiler.runAsync(); |
| 8 | + expect(stats.hasWarnings()).toBe(false); |
12 | 9 | }); |
13 | 10 |
|
14 | | - it('should emit warnings if emitWarning is undefined', (done) => { |
| 11 | + it('should emit warnings if emitWarning is undefined', async () => { |
15 | 12 | const compiler = pack('warn', {}); |
16 | 13 |
|
17 | | - compiler.run((err, stats) => { |
18 | | - expect(err).toBeNull(); |
19 | | - expect(stats.hasWarnings()).toBe(true); |
20 | | - done(); |
21 | | - }); |
| 14 | + const stats = await compiler.runAsync(); |
| 15 | + expect(stats.hasWarnings()).toBe(true); |
22 | 16 | }); |
23 | 17 |
|
24 | | - it('should emit warnings if emitWarning is true', (done) => { |
| 18 | + it('should emit warnings if emitWarning is true', async () => { |
25 | 19 | const compiler = pack('warn', { emitWarning: true }); |
26 | 20 |
|
27 | | - compiler.run((err, stats) => { |
28 | | - expect(err).toBeNull(); |
29 | | - expect(stats.hasWarnings()).toBe(true); |
30 | | - done(); |
31 | | - }); |
| 21 | + const stats = await compiler.runAsync(); |
| 22 | + expect(stats.hasWarnings()).toBe(true); |
32 | 23 | }); |
33 | 24 |
|
34 | | - it('should emit warnings, but not warnings if emitWarning is true and emitError is false', (done) => { |
| 25 | + it('should emit warnings, but not warnings if emitWarning is true and emitError is false', async () => { |
35 | 26 | const compiler = pack('full-of-problems', { |
36 | 27 | emitWarning: true, |
37 | 28 | emitError: false, |
38 | 29 | }); |
39 | 30 |
|
40 | | - compiler.run((err, stats) => { |
41 | | - expect(err).toBeNull(); |
42 | | - expect(stats.hasWarnings()).toBe(true); |
43 | | - expect(stats.hasErrors()).toBe(false); |
44 | | - done(); |
45 | | - }); |
| 31 | + const stats = await compiler.runAsync(); |
| 32 | + expect(stats.hasWarnings()).toBe(true); |
| 33 | + expect(stats.hasErrors()).toBe(false); |
46 | 34 | }); |
47 | 35 |
|
48 | | - it('should emit warnings and errors if emitWarning is true and emitError is undefined', (done) => { |
| 36 | + it('should emit warnings and errors if emitWarning is true and emitError is undefined', async () => { |
49 | 37 | const compiler = pack('full-of-problems', { emitWarning: true }); |
50 | 38 |
|
51 | | - compiler.run((err, stats) => { |
52 | | - expect(err).toBeNull(); |
53 | | - expect(stats.hasWarnings()).toBe(true); |
54 | | - expect(stats.hasErrors()).toBe(true); |
55 | | - done(); |
56 | | - }); |
| 39 | + const stats = await compiler.runAsync(); |
| 40 | + expect(stats.hasWarnings()).toBe(true); |
| 41 | + expect(stats.hasErrors()).toBe(true); |
57 | 42 | }); |
58 | 43 | }); |
0 commit comments