-
-
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.
Analyze selector browser hacks, refs #3
- Loading branch information
1 parent
b211652
commit d6f1efc
Showing
9 changed files
with
112 additions
and
96 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,11 @@ | ||
const isBrowserHack = require('css-selector-browser-h4cks-analyzer') | ||
const uniquer = require('../../utils/uniquer.js') | ||
|
||
module.exports = selectors => { | ||
const all = selectors.filter(isBrowserHack) | ||
|
||
return { | ||
total: all.length, | ||
...uniquer(all) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const test = require('ava') | ||
const analyze = require('../../../src/analyzer/selectors/browserhacks.js') | ||
|
||
test('It responds with the correct structure', t => { | ||
const actual = analyze([]) | ||
const expected = { | ||
total: 0, | ||
unique: [], | ||
totalUnique: 0 | ||
} | ||
|
||
t.deepEqual(actual, expected) | ||
}) | ||
|
||
test('It recognizes browser hacks correctly', t => { | ||
const actual = analyze(['* html .selector']) | ||
const expected = { | ||
total: 1, | ||
unique: [ | ||
{ | ||
value: '* html .selector', | ||
count: 1 | ||
} | ||
], | ||
totalUnique: 1 | ||
} | ||
|
||
t.deepEqual(actual, expected) | ||
}) | ||
|
||
test('It does not report values that are not browser hacks', t => { | ||
const expected = { | ||
total: 0, | ||
unique: [], | ||
totalUnique: 0 | ||
} | ||
|
||
const actual = analyze(['html']) | ||
|
||
t.deepEqual(actual, expected) | ||
}) |
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