-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.test.js
32 lines (28 loc) · 936 Bytes
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
let postcss = require('postcss')
let plugin = require('./')
function run(another, opts) {
return function () {
return postcss([another, plugin(opts)]).process('a{}').css
}
}
it('does not do anything without warnings', () => {
expect(run(() => {})).not.toThrow()
})
it('throws first warning', () => {
jest.spyOn(console, 'warn').mockImplementation(() => {})
expect(
run((root, result) => {
root.warn(result, 'Test 1', { plugin: 'postcss-test' })
result.warn('Test 2')
result.warn('Test 3', { plugin: 'postcss-test' })
root.warn(result, 'Test 4', { plugin: 'postcss-test' })
})
).toThrow('Test 1')
expect(console.warn).toHaveBeenCalledTimes(3)
expect(console.warn).toHaveBeenNthCalledWith(1, 'Test 2')
expect(console.warn).toHaveBeenNthCalledWith(2, 'postcss-test: Test 3')
expect(console.warn).toHaveBeenNthCalledWith(
3,
'postcss-test: <css input>:1:1: Test 4'
)
})