Skip to content

Commit 8d8aa7c

Browse files
committed
Add Istanbul for coverage, achieve 100% coverage. Add travis, add travis
badge; add coveralls, add coveralls badge
1 parent eb8af8d commit 8d8aa7c

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
coverage

.travis.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- stable
5+
script:
6+
- npm run lint
7+
- npm run test:cov
8+
- npm run test:coveralls

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Build Status](https://travis-ci.org/pl12133/css-object-loader.svg?branch=master)](https://travis-ci.org/pl12133/css-object-loader)[![Coverage Status](https://coveralls.io/repos/github/pl12133/css-object-loader/badge.svg?branch=master)](https://coveralls.io/github/pl12133/css-object-loader?branch=master)
2+
13
<p align="center">
24
<img src='http://i.imgur.com/PXYAzQE.png' title='CSS Object Loader' alt='CSS Object Loader'></img>
35
</p>

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"lint": "./node_modules/.bin/eslint src test",
99
"lint:fix": "./node_modules/.bin/eslint src test --fix",
1010
"test": "./node_modules/.bin/mocha",
11-
"prepublish": "npm run lint && npm run test"
11+
"test:cov": "node ./node_modules/.bin/istanbul cover --root src/ ./node_modules/.bin/_mocha",
12+
"test:coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
13+
"prepublish": "npm run lint && npm run test:cov"
1214
},
1315
"repository": {
1416
"type": "git",
@@ -21,11 +23,13 @@
2123
},
2224
"devDependencies": {
2325
"chai": "^3.5.0",
26+
"coveralls": "^2.11.9",
2427
"eslint": "^2.9.0",
2528
"eslint-config-semistandard": "^6.0.1",
2629
"eslint-config-standard": "^5.2.0",
2730
"eslint-plugin-promise": "^1.1.0",
2831
"eslint-plugin-standard": "^1.3.2",
32+
"istanbul": "^0.4.3",
2933
"mocha": "^2.4.5"
3034
}
3135
}

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var camelCase = require('camelcase');
88
// 1. Parse CSS stylesheet to AST
99
// 2. Flatten AST to Object of shape { [rule.selector]: rule.declarations }
1010
module.exports = function cssObjectLoader (source) {
11+
/* istanbul ignore next */
1112
this.cacheable && this.cacheable();
1213
// Step 1.
1314
var parsedStylesheet = getParsedStylesheet(source);

test/index.spec.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ describe('css-object-loader', () => {
2323

2424
it('should be able to transform css', () => {
2525
expect({
26-
p: {
27-
fontSize: '14px',
28-
fontWeight: 'bold'
29-
}
30-
}).to.deep.equal(actual);
26+
fontSize: '14px',
27+
fontWeight: 'bold'
28+
}).to.deep.equal(actual['p']);
29+
30+
expect({
31+
background: 'green',
32+
textAlign: 'center'
33+
}).to.deep.equal(actual['h1']);
3134
});
3235
});

test/style-spec.css

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1+
/* An animation key to cover the `!isValidRule(...)` branch */
2+
@keyframes someanimation {
3+
0%, 100% { left: 0; }
4+
50% { left:100%; }
5+
}
6+
17
p {
8+
/* the loader should be able to handle comments */
29
font-size: 14px;
310
font-weight: bold;
411
}
12+
13+
h1 {
14+
background: green;
15+
text-align: center;
16+
}

0 commit comments

Comments
 (0)