-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07f4610
commit bf5605b
Showing
4 changed files
with
62 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [] | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.