-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
57 lines (50 loc) · 1.67 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const postcss = require('postcss');
const fs = require('fs');
const plugin = require('./');
const css = fs.readFileSync('index.test.css', 'utf-8');
const opts = {
prefix: '#'
};
it('should not modify any output CSS', () => {
return postcss([plugin]).process(css)
.then(result => {
expect(result.css).toEqual(css);
});
});
it('should only push comments that have annotations', () => {
return postcss([plugin]).process(css)
.then(result => {
expect(result.commentAnnotations).toHaveLength(1);
});
});
it('should create property for default prefixed keys', () => {
return postcss([plugin]).process(css)
.then(result => {
expect(result.commentAnnotations[0]).toHaveProperty('foo');
});
});
it('should use option prefix to create properties', () => {
return postcss([plugin(opts)]).process(css)
.then(result => {
expect(result.commentAnnotations[0]).toHaveProperty('foo');
});
});
it('should create a value for single line annotations', () => {
return postcss([plugin]).process(css)
.then(result => {
expect(result.commentAnnotations[0]).toHaveProperty('foo', 'Bar');
});
});
it('should create a value for multi line annotations', () => {
return postcss([plugin]).process(css)
.then(result => {
expect(result.commentAnnotations[0])
.toHaveProperty('qux', 'Foo bar\nbaz qux');
});
});
it('should take key without value as boolean', () => {
return postcss([plugin]).process(css)
.then(result => {
expect(result.commentAnnotations[0]).toHaveProperty('baz', true);
});
});