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