Skip to content
This repository was archived by the owner on Oct 28, 2020. It is now read-only.

Commit da2799d

Browse files
author
TED Vortex (Teodor Eugen Dutulescu)
authored
Merge pull request #49 from superleap/gils13-mocha-tests
Gils13 mocha tests
2 parents 4bf1908 + 709e66e commit da2799d

23 files changed

+970
-17
lines changed

.bithoundrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
"engine": "eslint"
1414
},
1515
"wc": {
16-
"limit": 1000
16+
"limit": 1500
1717
}
18+
},
19+
"dependencies": {
20+
"mute": [
21+
"gulp-spawn-mocha"
22+
]
1823
}
1924
}

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ build/
33
node_modules/
44
lib/
55
examples/
6+
test/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,5 @@ jsx/
215215
material-ui/
216216
svg/
217217
.publish/
218+
.nyc_output/
218219
lib/

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ before_install:
2121
before_script:
2222
- npm prune
2323
after_success:
24+
- bash <(curl -s https://codecov.io/bash)
2425
- npm run release
2526
branches:
2627
except:

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![current version](https://img.shields.io/npm/v/github-issues-label-sync.svg?style=flat-square)](https://www.npmjs.com/package/github-asana-tag-sync) [![current version](https://img.shields.io/node/v/github-issues-label-sync.svg?style=flat-square)](https://www.npmjs.com/package/github-asana-tag-sync)
66
[![Dependency Status](https://david-dm.org/superleap/github-issues-label-sync.svg)](https://david-dm.org/superleap/github-issues-label-sync) [![devDependency Status](https://david-dm.org/superleap/github-issues-label-sync/dev-status.svg)](https://david-dm.org/superleap/github-issues-label-sync#info=devDependencies)
77

8-
[![bitHound Overall Score](https://www.bithound.io/github/superleap/github-issues-label-sync/badges/score.svg)](https://www.bithound.io/github/superleap/github-issues-label-sync) [![bitHound Dependencies](https://www.bithound.io/github/superleap/github-issues-label-sync/badges/dependencies.svg)](https://www.bithound.io/github/superleap/github-issues-label-sync/master/dependencies/npm) [![bitHound Dev Dependencies](https://www.bithound.io/github/superleap/github-issues-label-sync/badges/devDependencies.svg)](https://www.bithound.io/github/superleap/github-issues-label-sync/master/dependencies/npm) [![bitHound Code](https://www.bithound.io/github/superleap/github-issues-label-sync/badges/code.svg)](https://www.bithound.io/github/superleap/github-issues-label-sync)
8+
[![codecov](https://codecov.io/gh/superleap/github-issues-label-sync/branch/master/graph/badge.svg)](https://codecov.io/gh/superleap/github-issues-label-sync) [![bitHound Overall Score](https://www.bithound.io/github/superleap/github-issues-label-sync/badges/score.svg)](https://www.bithound.io/github/superleap/github-issues-label-sync) [![bitHound Dependencies](https://www.bithound.io/github/superleap/github-issues-label-sync/badges/dependencies.svg)](https://www.bithound.io/github/superleap/github-issues-label-sync/master/dependencies/npm) [![bitHound Dev Dependencies](https://www.bithound.io/github/superleap/github-issues-label-sync/badges/devDependencies.svg)](https://www.bithound.io/github/superleap/github-issues-label-sync/master/dependencies/npm) [![bitHound Code](https://www.bithound.io/github/superleap/github-issues-label-sync/badges/code.svg)](https://www.bithound.io/github/superleap/github-issues-label-sync)
99

1010
[![License](http://img.shields.io/:license-BSD2-blue.svg?style=flat-square)](https://opensource.org/licenses/BSD-2-Clause) [![GitHub issues](https://img.shields.io/github/issues/superleap/github-issues-label-sync.svg)](https://github.com/superleap/github-issues-label-sync/issues) [![Join the chat at https://gitter.im/superleap/github-issues-label-sync](https://badges.gitter.im/superleap/github-issues-label-sync.svg)](https://gitter.im/superleap/github-issues-label-sync?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1111

@@ -251,6 +251,26 @@ githubIssuesLabelSync.createLabels(labels).then((response) => {
251251
});
252252
```
253253

254+
### Update a label
255+
256+
```
257+
githubIssuesLabelSync.updateLabel(labels[0]).then((response) => {
258+
console.log(response);
259+
}).catch((error) => {
260+
console.log(error.toJSON());
261+
});
262+
```
263+
264+
### Update multiple labels
265+
266+
```
267+
githubIssuesLabelSync.updateLabels(labels).then((response) => {
268+
console.log(response);
269+
}).catch((error) => {
270+
console.log(error.toJSON());
271+
});
272+
```
273+
254274
### Delete a label
255275

256276
```

codecov.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
comment:
2+
layout: "header, diff, tree"
3+
branches:
4+
- master
5+
- gils*
6+
7+
coverage:
8+
range: "80...100"
9+
status:
10+
project:
11+
default:
12+
target: "95%"
13+
threshold: "2.5%"
14+
patch: true
15+
changes: false
16+
notify:
17+
gitter:
18+
default:
19+
only_pulls: true

gulpfile.babel.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const paths = {
2121
"manual": "./build/manual",
2222
"src": "./src/*",
2323
"srcEsdoc": "./src",
24+
"srcTest": "./test/**/*.js",
2425
"compile": "./lib"
2526
};
2627

@@ -33,7 +34,7 @@ const paths = {
3334
* @param {String} [opts.stdio=`inherit`] - spawn environment inherits parent
3435
* @return {Promise<Error>}
3536
*/
36-
function spawnp(proc, args = [], opts = { "stdio": `inherit` }) {
37+
function spawnp(proc, args = [], opts = {"stdio": `inherit`}) {
3738
return new Promise((resolve, reject) => {
3839
const child = spawn(proc, args, opts);
3940

@@ -187,11 +188,22 @@ gulp.task(`setup`, [`clean`], () => {
187188
});
188189
});
189190

191+
gulp.task(`test:code`, () => {
192+
return gulp.src([paths.srcTest])
193+
.pipe(gp.spawnMocha({
194+
"env": {
195+
"NODE_ENV": 'test'
196+
},
197+
"R": 'spec',
198+
"r": 'babel-register',
199+
"istanbul": false
200+
}));
201+
});
202+
190203

191204
gulp.task(`test:install`, [`nsp`, `snyk`, `bithound`]);
192205
gulp.task(`test:publish`, [`package`]);
193-
gulp.task(`test`, [`lint`]);
194206
gulp.task(`clean`, [`clean:docs`, `clean:manual`]);
195207
gulp.task(`postinstall`, [`test:install`]);
196208
gulp.task(`prepublish`, [`test:publish`]);
197-
gulp.task(`default`, [`test`]);
209+
gulp.task(`default`, [`test:code`, `lint`]);

package.json

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"node": ">=4"
77
},
88
"scripts": {
9-
"test": "gulp",
9+
"test": "nyc gulp",
1010
"prepublish": "gulp prepublish",
1111
"deploy": "gulp deploy",
1212
"release": "semantic-release pre && npm publish && semantic-release post"
@@ -39,34 +39,36 @@
3939
"@semantic-release/last-release-npm": "https://github.com/vrtxf/last-release-npm/tarball/da5a0f2411e2add6f5b0b990b4a12fad3245cfac",
4040
"babel-core": "^6.11.4",
4141
"babel-plugin-add-module-exports": "^0.2.1",
42+
"babel-plugin-istanbul": "^1.0.3",
4243
"babel-plugin-transform-es2015-block-scoping": "^6.10.1",
4344
"babel-preset-es2015": "^6.9.0",
4445
"babel-register": "^6.11.6",
4546
"bithound": "1.7.0",
46-
"commitizen": "^2.8.2",
47+
"chai": "^3.5.0",
48+
"chai-as-promised": "^5.3.0",
49+
"commitizen": "^2.8.4",
4750
"cz-conventional-changelog": "^1.1.6",
4851
"del": "^2.2.1",
4952
"esdoc": "^0.4.7",
5053
"esdoc-hacker-vision": "^1.1.0",
5154
"esdoc-node": "^1.0.0",
52-
"eslint": "^3.2.0",
55+
"eslint": "^3.2.2",
5356
"gulp": "^3.9.1",
5457
"gulp-babel": "^6.1.2",
55-
"gulp-codecov": "^2.0.2",
5658
"gulp-esdoc": "^0.2.0",
5759
"gulp-eslint": "^3.0.1",
5860
"gulp-exclude-gitignore": "^1.0.0",
5961
"gulp-gh-pages": "^0.5.4",
60-
"gulp-istanbul": "^1.0.0",
6162
"gulp-load-plugins": "^1.2.4",
62-
"gulp-mocha": "^2.2.0",
6363
"gulp-nsp": "^2.4.2",
64-
"gulp-plumber": "^1.1.0",
64+
"gulp-spawn-mocha": "^3.0.0",
6565
"mkdirp": "^0.5.1",
66-
"mocha": "^2.5.3",
66+
"mocha": "^3.0.1",
6767
"nsp": "^2.6.1",
68+
"nyc": "^7.1.0",
6869
"read-package-json": "^2.0.4",
6970
"semantic-release": "^6.3.0",
71+
"sinon": "^1.17.5",
7072
"snyk": "^1.17.5",
7173
"standard-changelog": "0.0.1"
7274
},
@@ -87,6 +89,32 @@
8789
"plugins": [
8890
"add-module-exports",
8991
"transform-es2015-block-scoping"
90-
]
92+
],
93+
"env": {
94+
"test": {
95+
"plugins": [
96+
"istanbul"
97+
]
98+
}
99+
}
100+
},
101+
"nyc": {
102+
"lines": 95,
103+
"statements": 95,
104+
"functions": 95,
105+
"branches": 95,
106+
"include": [
107+
"src/**/*.js"
108+
],
109+
"reporter": [
110+
"lcov",
111+
"text-summary"
112+
],
113+
"require": [
114+
"babel-register"
115+
],
116+
"sourceMap": false,
117+
"instrument": false,
118+
"check-coverage": true
91119
}
92120
}

src/LabelSync.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export default class GithubIssuesLabelSync {
316316
let success = true;
317317

318318
if (error) {
319-
if (error.toJSON().code === 404) {
319+
if (error.code === 404) {
320320
label.status = 'not found';
321321
} else {
322322
success = false;
@@ -379,14 +379,13 @@ export default class GithubIssuesLabelSync {
379379
let success = true;
380380

381381
if (error) {
382-
if (JSON.parse(error.toJSON().message).errors[0].code === 'already_exists') {
382+
if (error.code === 422 && JSON.parse(error.message).errors[0].code === 'already_exists') {
383383
label.status = 'duplicate';
384384
} else {
385385
success = false;
386386
reject(error);
387387
}
388388
} else {
389-
success = true;
390389
label.status = 'success';
391390
}
392391

test/LabelSync/constructorTest.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import chai from 'chai';
2+
import chaiAsPromised from 'chai-as-promised';
3+
import sinon from 'sinon';
4+
import config from './../test-config';
5+
6+
let expect = chai.expect;
7+
let LabelSync = require('./../../src/LabelSync');
8+
9+
chai.use(chaiAsPromised);
10+
11+
/**
12+
* @test {LabelSync}
13+
*/
14+
describe('LabelSync#constructor', () => {
15+
let LabelSyncTest;
16+
let authenticate;
17+
18+
beforeEach(() => {
19+
LabelSyncTest = new LabelSync(undefined, config.user, config.repo, config.token);
20+
});
21+
22+
/**
23+
* @test {LabelSync#constructor}
24+
*/
25+
it('should be able to setup the class with default parameters', (done) => {
26+
authenticate = sinon.stub(LabelSyncTest, 'authenticate');
27+
expect(LabelSyncTest).to.be.an('object');
28+
authenticate.restore();
29+
done();
30+
});
31+
});

0 commit comments

Comments
 (0)