Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Commit

Permalink
Add istanbul & codacy reporting
Browse files Browse the repository at this point in the history
- Downgrade WCT
- Add istanbul
- Add codacy & reporting task
- Exclude coverage folder from appropriate checks
  • Loading branch information
marclove committed Jan 12, 2017
1 parent c83a146 commit c36b3f1
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 114 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
build
lib
/bower_components
/coverage
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "Autodesk Inc.",
"license": "Apache-2.0",
"devDependencies": {
"web-component-tester": "^5.0.0",
"web-component-tester": "4.2.2",
"webcomponentsjs": "^0.7.23"
}
}
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"description": "the autodesk ui library",
"main": "index.js",
"scripts": {
"test": "npm run compile && lerna run lint && npm run specs && npm run test-components && npm run ensure-copyright",
"test-ci": "npm run compile && lerna run lint && npm run specs && npm run test-components-sauce && npm run ensure-copyright",
"test": "npm run compile && lerna run lint && npm run specs && npm run browserify && wct && npm run ensure-copyright",
"test-ci": "npm run compile && lerna run lint && npm run specs && npm run browserify && wct --plugin sauce --skip-plugin local && npm run ensure-copyright && npm run report-coverage",
"build": "lerna run build",
"clean": "node ./packages/scripts/orion.js clean",
"compile": "node ./packages/scripts/orion.js compile",
Expand All @@ -15,9 +15,10 @@
"copy-package-builds": "node ./packages/scripts/orion.js copy-package-builds",
"ensure-copyright": "node ./packages/scripts/orion.js ensure-copyright --dir ./",
"specs": "NODE_ENV=test mocha --compilers js:babel-core/register './packages/!(react-playground)/{,!(node_modules|lib|build)/**/}*.test.js'",
"browserify": "mkdir -p build && browserify packages/components/lib/index.js -o build/bundle.js",
"test-components": "npm run browserify && wct",
"test-components-sauce": "npm run browserify && wct --plugin sauce --skip-plugin local"
"browserify": "mkdir -p build && browserify test/bundle.js packages/components/lib/index.js -o build/bundle.js",
"test-components": "npm run compile && npm run browserify && wct",
"test-components-sauce": "npm run compile && npm run browserify && wct --plugin sauce --skip-plugin local",
"report-coverage": "cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage"
},
"repository": {
"type": "git",
Expand All @@ -36,17 +37,18 @@
"browserify": "^13.3.0",
"chai": "^3.5.0",
"chai-enzyme": "^0.6.1",
"codacy-coverage": "^2.0.0",
"enzyme": "^2.6.0",
"es6-promise": "^4.0.5",
"eslint": "^3.11.1",
"jsdom": "9.8.3",
"jsdom-global": "2.1.0",
"lerna": "2.0.0-beta.31",
"mocha": "^3.2.0",
"nock": "^9.0.2",
"react": "^15.4.1",
"react-addons-test-utils": "^15.4.1",
"react-dom": "^15.4.1",
"web-component-tester": "^5.0.0"
"web-component-tester": "4.2.2",
"web-component-tester-istanbul": "^0.10.0"
}
}
71 changes: 0 additions & 71 deletions packages/components/src/2016-12-01/button-state.test.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/components/src/2016-12-01/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Button extends HTMLElement {
});

this.addEventListener('mouseleave', () => {
if (this.state.disabled) { return; }
const nextState = ButtonState.leaveHover(this.state);
this.dispatchEvent(new CustomEvent('change', {
detail: {
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/2016-12-01/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ limitations under the License.
*/
const Button = require('./button');
const Inline = require('./inline');
const ButtonState = require('./button-state');

module.exports = { Button, Inline };
module.exports = { Button, Inline, ButtonState };
18 changes: 0 additions & 18 deletions packages/react/src/2016-12-01/button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ require('jsdom-global/register');
const React = require('react');
const { mount } = require('enzyme');
const chai = require('chai');
const sinon = require('sinon');
const chaiEnzyme = require('chai-enzyme');

const expect = chai.expect;
Expand All @@ -42,21 +41,4 @@ describe('<OrionButton />', () => {
expect(element.background).to.equal(props.background);
expect(element.color).to.equal(props.color);
});

it('simulates click events', () => {
const onClick = sinon.spy();
const wrapper = mount(<OrionButton onClick={onClick} />);
wrapper.find('orion-button').get(0).dispatchEvent(new Event('click'));
expect(onClick).to.have.property('callCount', 1);
});

context('when disabled', () => {
it('does not simulate click events', () => {
const onClick = sinon.spy();
const wrapper = mount(<OrionButton onClick={onClick} disabled />);
wrapper.find('orion-button').simulate('click');

expect(onClick).to.have.property('callCount', 0);
});
});
});
2 changes: 1 addition & 1 deletion packages/scripts/orion-ensure-copyright.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function hasCopyrightNotice(file) {
}

function ensureCopyright(dir) {
const files = glob.sync(path.join(dir, '**/*.js'), { ignore: ['**/node_modules/**', '**/bower_components/**', '**/vendor/**'] });
const files = glob.sync(path.join(dir, '**/*.js'), { ignore: ['**/node_modules/**', '**/bower_components/**', '**/coverage/**', '**/vendor/**'] });
const result = files.reduce((memo, file) => {
if (hasCopyrightNotice(file)) {
memo.pass.push(file);
Expand Down
22 changes: 22 additions & 0 deletions test/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

/**
Copyright 2016 Autodesk,Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

const _components = require('../packages/components/lib/2016-12-01/index');
window.Button = _components.Button;
window.ButtonState = _components.ButtonState;
77 changes: 77 additions & 0 deletions test/button-state.test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!doctype html>

<!--
Copyright 2016 Autodesk,Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<html>
<head>
<meta charset="utf-8">
<script src="../bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<script src="../bower_components/web-component-tester/browser.js"></script>
<script src="../build/bundle.js"></script>
</head>

<body>
<script>
describe('ButtonState', () => {
describe('getInitialState', () => {
it('returns a default state', () => {
const initialState = ButtonState.getInitialState();
expect(initialState.disabled).to.be.false;
expect(initialState.focus).to.be.false;
expect(initialState.hover).to.be.false;
});

context('with a state', () => {
it('extends default state with passed state', () => {
const initialState = ButtonState.getInitialState({ disabled: true });
expect(initialState.disabled).to.be.true;
expect(initialState.focus).to.be.false;
expect(initialState.hover).to.be.false;
});
});
});

describe('enterHover', () => {
it('sets hover to true', () => {
const nextState = ButtonState.enterHover({ hover: false });
expect(nextState.hover).to.be.true;
});
});

describe('leaveHover', () => {
it('sets hover to false', () => {
const nextState = ButtonState.leaveHover({ hover: true });
expect(nextState.hover).to.be.false;
});
});

describe('enterDisabled', () => {
it('sets disabled to true', () => {
const nextState = ButtonState.enterDisabled({ disabled: false });
expect(nextState.disabled).to.be.true;
});
});

describe('leaveDisabled', () => {
it('sets disabled to false', () => {
const nextState = ButtonState.leaveDisabled({ disabled: true });
expect(nextState.disabled).to.be.false;
});
});
});
</script>
</body>
</html>

0 comments on commit c36b3f1

Please sign in to comment.