Skip to content

Commit bf5605b

Browse files
authored
add charset tests (#109)
1 parent 07f4610 commit bf5605b

File tree

4 files changed

+62
-22
lines changed

4 files changed

+62
-22
lines changed

test/analyzer/atrules/atrules.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const test = require('ava')
2+
const analyze = require('../../../src/analyzer/atrules/charsets')
3+
4+
const FIXTURE = [
5+
{
6+
type: 'charset',
7+
params: 'B'
8+
},
9+
{
10+
type: 'charset',
11+
params: 'A'
12+
},
13+
{
14+
type: 'charset',
15+
params: 'A'
16+
}
17+
]
18+
19+
test('it responds with the correct structure', t => [
20+
t.deepEqual(analyze([]), {
21+
total: 0,
22+
totalUnique: 0,
23+
unique: []
24+
})
25+
])
26+
27+
test('it counts charsets', t => {
28+
const {total: actual} = analyze(FIXTURE)
29+
30+
t.is(actual, 3)
31+
})
32+
33+
test('it finds all unique charsets and counts and sorts them', t => {
34+
const {unique: actual} = analyze(FIXTURE)
35+
36+
t.deepEqual(actual, [{count: 2, value: 'A'}, {value: 'B', count: 1}])
37+
})
38+
39+
test('it counts unique charsets', t => {
40+
const {totalUnique: actual} = analyze(FIXTURE)
41+
42+
t.is(actual, 2)
43+
})
44+
45+
test('it does not report non-charset atrules as charset', t => {
46+
const actual = analyze([
47+
{
48+
type: 'media',
49+
params: 'X'
50+
},
51+
{
52+
type: 'document',
53+
params: 'X'
54+
}
55+
])
56+
57+
t.deepEqual(actual, {
58+
total: 0,
59+
totalUnique: 0,
60+
unique: []
61+
})
62+
})

test/analyzer/atrules/charsets/index.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/analyzer/atrules/charsets/input.css

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/analyzer/atrules/charsets/output.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)