Skip to content

Commit 0709add

Browse files
committed
chore: add some CI testing
1 parent 3d312dc commit 0709add

File tree

8 files changed

+89
-52
lines changed

8 files changed

+89
-52
lines changed

.circleci/config.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 2
2+
jobs:
3+
build:
4+
working_directory: ~/vue-material-design-icons
5+
docker:
6+
- image: node:12-alpine
7+
steps:
8+
- run:
9+
name: Install certificate handling for artifact uploading
10+
command: apk add ca-certificates
11+
- checkout
12+
- run:
13+
name: Install dependencies
14+
command: yarn
15+
- run:
16+
name: Run tests
17+
command: yarn test
18+
- store_artifacts:
19+
path: coverage
20+
prefix: coverage
21+
- store_test_results:
22+
path: coverage

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ node_modules/
66
dist/
77
yarn.lock
88
package-lock.json
9+
coverage/

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10
1+
12

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"arrowParens": "always",
3+
"trailingComma": "all",
4+
"singleQuote": true,
5+
"htmlWhitespaceSensitivity": "ignore"
6+
}

__tests__/icon.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
import { shallowMount } from "@vue/test-utils";
2-
import AndroidIcon from "../dist/Android.vue";
1+
import { shallowMount } from '@vue/test-utils';
2+
import AndroidIcon from '../dist/Android';
33

4-
describe("Icon", () => {
4+
describe('Icon', () => {
55
let icon;
66

77
beforeEach(() => {
88
icon = shallowMount(AndroidIcon);
99
});
1010

11-
it("accepts a \"title\" property", () => {
12-
expect(icon.vm.title).toEqual("Android icon");
13-
expect(icon.attributes()["aria-label"]).toEqual("Android icon");
11+
it('accepts a "title" property', () => {
12+
expect(icon.vm.title).toEqual('Android icon');
13+
expect(icon.attributes()['aria-label']).toEqual('Android icon');
1414

15-
icon.setProps({ title: "foo" });
15+
icon.setProps({ title: 'foo' });
1616

17-
expect(icon.vm.title).toEqual("foo");
18-
expect(icon.attributes()["aria-label"]).toEqual("foo");
17+
expect(icon.vm.title).toEqual('foo');
18+
expect(icon.attributes()['aria-label']).toEqual('foo');
1919
});
2020

21-
it("accepts a \"decorative\" property", () => {
21+
it('accepts a "decorative" property', () => {
2222
expect(icon.vm.decorative).toBe(false);
23-
expect(icon.attributes()["aria-hidden"]).toBeFalsy();
23+
expect(icon.attributes()['aria-hidden']).toBeFalsy();
2424

2525
icon.setProps({ decorative: true });
2626

2727
expect(icon.vm.decorative).toBe(true);
28-
expect(icon.attributes()["aria-hidden"]).toBeTruthy();
28+
expect(icon.attributes()['aria-hidden']).toBeTruthy();
2929
});
3030

31-
it("accepts a \"fillColor\" property", () => {
32-
const svg = icon.find(".material-design-icon__svg");
31+
it('accepts a "fillColor" property', () => {
32+
const svg = icon.find('.material-design-icon__svg');
3333

34-
expect(icon.vm.fillColor).toBe("currentColor");
35-
expect(svg.attributes()["fill"]).toEqual("currentColor");
34+
expect(icon.vm.fillColor).toBe('currentColor');
35+
expect(svg.attributes()['fill']).toEqual('currentColor');
3636

37-
icon.setProps({ fillColor: "#FF0000" });
37+
icon.setProps({ fillColor: '#FF0000' });
3838

39-
expect(icon.vm.fillColor).toBe("#FF0000");
40-
expect(svg.attributes()["fill"]).toEqual("#FF0000");
39+
expect(icon.vm.fillColor).toBe('#FF0000');
40+
expect(svg.attributes()['fill']).toEqual('#FF0000');
4141
});
4242

43-
it("renders an icon", () => {
43+
it('renders an icon', () => {
4444
expect(icon).toMatchSnapshot();
4545
});
4646
});

build.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
#!/usr/bin/env node
22

33
// Imports
4-
const fs = require("fs");
5-
const fsp = require("fs").promises;
6-
const mustache = require("mustache");
7-
const path = require("path");
8-
const icons = require("@mdi/js/commonjs/mdi.js");
9-
const dist = path.resolve(__dirname, "dist");
10-
const templateFile = path.resolve(__dirname, "template.mst");
4+
const fs = require('fs');
5+
const fsp = require('fs').promises;
6+
const mustache = require('mustache');
7+
const path = require('path');
8+
const icons = require('@mdi/js/commonjs/mdi.js');
9+
const dist = path.resolve(__dirname, 'dist');
10+
const templateFile = path.resolve(__dirname, 'template.mst');
1111
const iconIDs = Object.keys(icons);
1212

13-
const templateData = iconIDs.map(id => {
13+
const templateData = iconIDs.map((id) => {
1414
const splitID = id.split(/(?=[A-Z])/).slice(1);
1515

16-
const name = splitID.join("");
16+
const name = splitID.join('');
1717

1818
// This is a hacky way to remove the 'mdi' prefix, so "mdiAndroid" becomes
1919
// "android", for example
20-
const title = splitID.join("-").toLowerCase();
20+
const title = splitID.join('-').toLowerCase();
2121

2222
// Transforms the icon ID to a human readable form for default titles.
2323
// For example, "mdiAndroidStudio" becomes "Android Studio"
24-
const readableName = splitID.join(" ");
24+
const readableName = splitID.join(' ');
2525

2626
return {
2727
name,
2828
title,
2929
readableName,
30-
svgPathData: icons[id]
30+
svgPathData: icons[id],
3131
};
3232
});
3333

3434
const generateIcons = async () => {
35-
const template = fs.readFileSync(templateFile, { encoding: "utf8" });
35+
const template = fs.readFileSync(templateFile, { encoding: 'utf8' });
3636

3737
if (!fs.existsSync(dist)) {
3838
fs.mkdirSync(dist);
@@ -44,11 +44,11 @@ const generateIcons = async () => {
4444
name,
4545
title,
4646
readableName,
47-
svgPathData
47+
svgPathData,
4848
});
4949
const filename = `${name}.vue`;
5050
return fsp.writeFile(path.resolve(dist, filename), component);
51-
}
51+
},
5252
);
5353

5454
Promise.all(filePromises);

jest.config.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
module.exports = {
2-
"verbose": true,
3-
"moduleFileExtensions": [
4-
"js",
5-
"vue"
6-
],
7-
"transform": {
8-
"^.+\\.vue$": "vue-jest",
9-
"^.+\\.js$": "<rootDir>/node_modules/babel-jest"
2+
verbose: true,
3+
moduleFileExtensions: ['js', 'vue'],
4+
transform: {
5+
'^.+\\.vue$': 'vue-jest',
6+
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
107
},
11-
"snapshotSerializers": [
12-
"<rootDir>/node_modules/jest-serializer-vue"
13-
]
8+
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
9+
collectCoverage: true,
10+
coverageThreshold: {
11+
global: {
12+
branches: 100,
13+
functions: 100,
14+
lines: 100,
15+
statements: 100,
16+
},
17+
},
18+
reporters: ['default', 'jest-junit'],
1419
};

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
"babel-core": "7.0.0-bridge.0",
2525
"babel-jest": "^24.8.0",
2626
"jest": "^24.8.0",
27+
"jest-junit": "^6.4.0",
2728
"jest-serializer-vue": "2.0.2",
2829
"mustache": "^3.0.1",
30+
"prettier": "^1.18.2",
2931
"regenerator-runtime": "^0.13.2",
3032
"standard-version": "^6.0.1",
3133
"vue": "^2.6.10",
@@ -37,12 +39,13 @@
3739
"url": "https://gitlab.com/robcresswell/vue-material-design-icons/issues"
3840
},
3941
"scripts": {
40-
"prebuild": "npm ci && npm run clean",
42+
"prebuild": "yarn clean",
4143
"build": "./build.js && cp styles.css dist/",
4244
"clean": "rm -rf dist/",
43-
"pretest": "npm run build",
44-
"test": "jest",
45-
"prerelease": "npm run build",
46-
"release": "standard-version --sign --tag-prefix '' && cp package.json README.md CHANGELOG.md dist/ && cd dist && npm publish"
45+
"format": "prettier --write **/*.{js,vue}",
46+
"pretest": "yarn build",
47+
"test": "JEST_JUNIT_OUTPUT='./coverage/junit.xml' jest",
48+
"prerelease": "yarn build",
49+
"release": "standard-version --sign --tag-prefix '' && cp package.json README.md CHANGELOG.md dist/ && cd dist && yarn publish"
4750
}
4851
}

0 commit comments

Comments
 (0)