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
Showing
7 changed files
with
122 additions
and
131 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
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
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
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 |
---|---|---|
@@ -1,9 +1,60 @@ | ||
const test = require('ava') | ||
const testScope = require('../../utils/scope-tester.js') | ||
const analyze = require('../../../src/analyzer/properties') | ||
|
||
const SCOPE = 'properties' | ||
test('it responds with the correct structure', t => { | ||
const actual = analyze([]) | ||
const expected = { | ||
total: 0, | ||
totalUnique: 0, | ||
unique: [], | ||
browserhacks: { | ||
total: 0, | ||
totalUnique: 0, | ||
unique: [] | ||
}, | ||
prefixed: { | ||
total: 0, | ||
totalUnique: 0, | ||
unique: [], | ||
share: 0 | ||
} | ||
} | ||
|
||
test(SCOPE, async t => { | ||
const {actual, expected} = await testScope(SCOPE) | ||
t.deepEqual(actual[SCOPE], expected) | ||
t.deepEqual(actual, expected) | ||
}) | ||
|
||
test('it counts all properties', t => { | ||
const fixture = [ | ||
{property: 'color', value: 'unset'}, | ||
{property: 'border', value: 'unset'}, | ||
{property: 'font-size', value: 'unset'} | ||
] | ||
const {total: actual} = analyze(fixture) | ||
const expected = 3 | ||
|
||
t.is(actual, expected) | ||
}) | ||
|
||
test('it lists all unique properties with their count and sorted alphabeticlly', t => { | ||
const fixture = [ | ||
{property: 'color', value: 'unset'}, | ||
{property: 'color', value: 'unset'}, | ||
{property: 'border', value: 'unset'} | ||
] | ||
const {unique: actual} = analyze(fixture) | ||
const expected = [{value: 'border', count: 1}, {value: 'color', count: 2}] | ||
|
||
t.deepEqual(actual, expected) | ||
}) | ||
|
||
test('it counts all unique properties', t => { | ||
const fixture = [ | ||
{property: 'color', value: 'unset'}, | ||
{property: 'color', value: 'unset'}, | ||
{property: 'border', value: 'unset'} | ||
] | ||
const {totalUnique: actual} = analyze(fixture) | ||
const expected = 2 | ||
|
||
t.is(actual, expected) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,55 @@ | ||
const test = require('ava') | ||
const analyze = require('../../../src/analyzer/properties/prefixed') | ||
|
||
test('it responds with the correct structure', t => { | ||
const actual = analyze([]) | ||
const expected = { | ||
total: 0, | ||
share: 0, | ||
totalUnique: 0, | ||
unique: [] | ||
} | ||
|
||
t.deepEqual(actual, expected) | ||
}) | ||
|
||
const FIXTURE = [ | ||
'color', | ||
'-webkit-animation', | ||
'-webkit-animation', // Duplicate | ||
'-moz-appearance' | ||
] | ||
|
||
test('it counts prefixed properties', t => { | ||
const {total: actual} = analyze(FIXTURE) | ||
|
||
t.is(actual, 3) | ||
}) | ||
|
||
test('it calculates the prefixed share', t => { | ||
const {share: actual} = analyze(FIXTURE) | ||
|
||
t.is(actual, 0.75) | ||
}) | ||
|
||
test('it finds the unique prefixed properties and counts and sorts them', t => { | ||
const {unique: actual} = analyze(FIXTURE) | ||
const expected = [ | ||
{ | ||
value: '-moz-appearance', | ||
count: 1 | ||
}, | ||
{ | ||
value: '-webkit-animation', | ||
count: 2 | ||
} | ||
] | ||
|
||
t.deepEqual(actual, expected) | ||
}) | ||
|
||
test('it counts the total unique prefixed properties', t => { | ||
const {totalUnique: actual} = analyze(FIXTURE) | ||
|
||
t.is(actual, 2) | ||
}) |