Skip to content

Commit

Permalink
add charset tests (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartveneman committed Mar 14, 2019
1 parent 07f4610 commit bf5605b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 22 deletions.
62 changes: 62 additions & 0 deletions test/analyzer/atrules/atrules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const test = require('ava')
const analyze = require('../../../src/analyzer/atrules/charsets')

const FIXTURE = [
{
type: 'charset',
params: 'B'
},
{
type: 'charset',
params: 'A'
},
{
type: 'charset',
params: 'A'
}
]

test('it responds with the correct structure', t => [
t.deepEqual(analyze([]), {
total: 0,
totalUnique: 0,
unique: []
})
])

test('it counts charsets', t => {
const {total: actual} = analyze(FIXTURE)

t.is(actual, 3)
})

test('it finds all unique charsets and counts and sorts them', t => {
const {unique: actual} = analyze(FIXTURE)

t.deepEqual(actual, [{count: 2, value: 'A'}, {value: 'B', count: 1}])
})

test('it counts unique charsets', t => {
const {totalUnique: actual} = analyze(FIXTURE)

t.is(actual, 2)
})

test('it does not report non-charset atrules as charset', t => {
const actual = analyze([
{
type: 'media',
params: 'X'
},
{
type: 'document',
params: 'X'
}
])

t.deepEqual(actual, {
total: 0,
totalUnique: 0,
unique: []
})
})
9 changes: 0 additions & 9 deletions test/analyzer/atrules/charsets/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions test/analyzer/atrules/charsets/input.css

This file was deleted.

8 changes: 0 additions & 8 deletions test/analyzer/atrules/charsets/output.json

This file was deleted.

0 comments on commit bf5605b

Please sign in to comment.