mirror of
https://github.com/simple-icons/simple-icons.git
synced 2024-11-26 01:00:27 +02:00
Test the NPM package (#972)
* Implement basic test for the NPM package Just an initial test suite that checks if all promised imports actually exist. The testing framework Jest was chosen because of it ease of setup and use. * Implement exhaustive tests of properties for each icon
This commit is contained in:
parent
e47433b9d9
commit
e6485072d2
@ -14,6 +14,15 @@ jobs:
|
|||||||
- gem install jekyll
|
- gem install jekyll
|
||||||
script:
|
script:
|
||||||
- jekyll build
|
- jekyll build
|
||||||
|
- name: "Test package"
|
||||||
|
language: node_js
|
||||||
|
node_js: 8
|
||||||
|
before_script:
|
||||||
|
- npm run prepublishOnly
|
||||||
|
script:
|
||||||
|
- npm run test
|
||||||
|
after_script:
|
||||||
|
- npm run postpublish
|
||||||
|
|
||||||
- stage: deploy
|
- stage: deploy
|
||||||
name: "NPM Package"
|
name: "NPM Package"
|
||||||
|
5319
package-lock.json
generated
5319
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -18,6 +18,7 @@
|
|||||||
"author": "Simple Icons Collaborators",
|
"author": "Simple Icons Collaborators",
|
||||||
"license": "CC0",
|
"license": "CC0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"jest": "^23.5.0",
|
||||||
"jsonlint2": "^1.7.1",
|
"jsonlint2": "^1.7.1",
|
||||||
"svglint": "^1.0.2"
|
"svglint": "^1.0.2"
|
||||||
},
|
},
|
||||||
@ -25,6 +26,7 @@
|
|||||||
"jsonlint": "jsonlint _data/simple-icons.json -q -V .jsonlintschema",
|
"jsonlint": "jsonlint _data/simple-icons.json -q -V .jsonlintschema",
|
||||||
"svglint": "svglint icons/* --ci",
|
"svglint": "svglint icons/* --ci",
|
||||||
"prepublishOnly": "node scripts/prepublish.js",
|
"prepublishOnly": "node scripts/prepublish.js",
|
||||||
"postpublish": "rm icons/*.js index.js"
|
"postpublish": "rm icons/*.js index.js",
|
||||||
|
"test": "jest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
24
tests/icons.test.js
Normal file
24
tests/icons.test.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
const { icons } = require('../_data/simple-icons.json');
|
||||||
|
const { titleToFilename } = require('../scripts/utils.js');
|
||||||
|
|
||||||
|
icons.forEach(icon => {
|
||||||
|
const filename = titleToFilename(icon.title);
|
||||||
|
const subject = require(`../icons/${filename}.js`);
|
||||||
|
|
||||||
|
test(`${icon.title} has a "title"`, () => {
|
||||||
|
expect(typeof subject.title).toBe('string');
|
||||||
|
});
|
||||||
|
|
||||||
|
test(`${icon.title} has a "hex" value`, () => {
|
||||||
|
expect(typeof subject.hex).toBe('string');
|
||||||
|
expect(subject.hex).toHaveLength(6);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(`${icon.title} has a "source"`, () => {
|
||||||
|
expect(typeof subject.source).toBe('string');
|
||||||
|
});
|
||||||
|
|
||||||
|
test(`${icon.title} has an "svg"`, () => {
|
||||||
|
expect(typeof subject.svg).toBe('string');
|
||||||
|
});
|
||||||
|
});
|
23
tests/index.test.js
Normal file
23
tests/index.test.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
const { icons } = require('../_data/simple-icons.json');
|
||||||
|
const simpleIcons = require('../index.js');
|
||||||
|
|
||||||
|
icons.forEach(icon => {
|
||||||
|
const subject = simpleIcons[icon.title];
|
||||||
|
|
||||||
|
test(`${icon.title} has a "title"`, () => {
|
||||||
|
expect(typeof subject.title).toBe('string');
|
||||||
|
});
|
||||||
|
|
||||||
|
test(`${icon.title} has a "hex" value`, () => {
|
||||||
|
expect(typeof subject.hex).toBe('string');
|
||||||
|
expect(subject.hex).toHaveLength(6);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(`${icon.title} has a "source"`, () => {
|
||||||
|
expect(typeof subject.source).toBe('string');
|
||||||
|
});
|
||||||
|
|
||||||
|
test(`${icon.title} has an "svg"`, () => {
|
||||||
|
expect(typeof subject.svg).toBe('string');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user