Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for duplicate icon names and fail when two icons have the same name #322

Merged
merged 9 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "9.1.0",
"scripts": {
"version": "script/version",
"test": "ava tests/*.js",
"test": "ava -v tests/*.js",
"lint": "eslint tests"
},
"dependencies": {
Expand Down
17 changes: 17 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const globby = require('globby')
const year = new Date().getFullYear()
const yearRegex = new RegExp(`Copyright \\(c\\) ${year} GitHub Inc\\.`)
const octiconsLib = fs.readdirSync('./lib/build/svg')
const octiconsData = require('../lib/build/data.json')

test(`LICENSE files have the current year ${year}`, t => {
return globby(['**/LICENSE', '!**/node_modules/**/LICENSE', '!**/vendor/**/LICENSE']).then(paths => {
Expand All @@ -19,3 +20,19 @@ test(`LICENSE files have the current year ${year}`, t => {
test('SVG icons exist', t => {
t.not(octiconsLib.length, 0, `We didn't find any svg files`)
})

test('Data file exist', t => {
t.not(octiconsData.length, 0, `We didn't find any data files`)
})

const names = {}
for (const o of Object.values(octiconsData)) {
jonrohan marked this conversation as resolved.
Show resolved Hide resolved
test(`No duplicate ${o.name} icon`, t => {
if (names[o.name]) {
t.fail(`Found duplicate '${o.name}' icons in the figma file. Please rename one of them.`)
jonrohan marked this conversation as resolved.
Show resolved Hide resolved
} else {
names[o.name] = o
t.pass()
}
})
}