core/api/img/octicons/10.0.0/tests/index.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-12-11 13:55:49 +05:00
const test = require('ava')
const fs = require('fs-extra')
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 => {
t.plan(paths.length)
return paths.map(path => {
const license = fs.readFileSync(path, 'utf8')
return t.regex(license, yearRegex, `The license "${path}" does not include the current year ${year}`)
})
})
})
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 octicon of Object.values(octiconsData)) {
test(`No duplicate ${octicon.name} icon`, t => {
if (names[octicon.name]) {
t.fail(
`Found duplicate '${
octicon.name
}' icons in the figma file. Please rename one of them. https://www.figma.com/file/${octicon.file}?node-id=${
octicon.id
}`
)
} else {
names[octicon.name] = octicon
t.pass()
}
})
}