Skip to content

Commit e74efb1

Browse files
author
Tom Kirkpatrick
committed
Switch to nyc for coverage tests
1 parent ede421f commit e74efb1

File tree

5 files changed

+56
-46
lines changed

5 files changed

+56
-46
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
.idea
1515
.project
1616
.strong-pm
17+
.nyc_output
1718
coverage
1819
node_modules
1920
npm-debug.log

package.json

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,39 @@
11
{
2-
"name": "fullcube-workflow",
2+
"name": "loopback-component-fsm",
3+
"description": "Finite State Machine for Loopback Models.",
34
"version": "0.1.0",
4-
"description": "Fullcube Workflow Engine",
5-
"main": "index.js",
5+
"author": {
6+
"name": "Tom Kirkpatrick @mrfelton"
7+
},
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/fullcube/loopback-component-fsm.git"
11+
},
12+
"keywords": [
13+
"loopback",
14+
"strongloop",
15+
"fsm"
16+
],
17+
"license": "MIT",
18+
"bugs": {
19+
"url": "https://github.com/fullcube/loopback-component-fsm/issues"
20+
},
21+
"homepage": "https://github.com/fullcube/loopback-component-fsm",
22+
"files": [
23+
"lib",
24+
"test"
25+
],
26+
"directories": {
27+
"lib": "lib",
28+
"test": "test"
29+
},
30+
"main": "lib/index.js",
631
"scripts": {
7-
"dev": "DEBUG=loopback:component:fsm nodemon test/fullcube-state-machine/server/server.js --ignore db.json --ext js,json",
8-
"test": "babel-node ./node_modules/.bin/isparta cover --report text --report lcov _mocha test/*test.js",
9-
"quicktest": "mocha test/*test.js",
32+
"dev": "nodemon test/fullcube-state-machine/server/server.js --ignore db.json --ext js,json",
33+
"test": "nyc --reporter=lcov --reporter=text mocha test/*test.js",
1034
"test:watch": "npm run test -- -w",
11-
"coverage": "cat ./coverage/lcov.info | coveralls"
35+
"coverage": "nyc report --reporter=text-lcov | coveralls"
1236
},
13-
"author": "",
14-
"license": "ISC",
1537
"devDependencies": {
1638
"babel-cli": "^6.10.1",
1739
"babel-core": "^6.10.4",
@@ -21,7 +43,7 @@
2143
"chai": "^3.5.0",
2244
"coveralls": "^2.11.9",
2345
"eslint-config-fullcube": "git+https://github.com/fullcube/eslint-config-fullcube.git",
24-
"isparta": "^4.0.0",
46+
"loglevel": "^1.4.1",
2547
"mocha": "^2.5.3",
2648
"nodemon": "^1.9.2",
2749
"sinon": "^1.17.4",
@@ -32,7 +54,12 @@
3254
"bluebird": "^3.4.1",
3355
"debug": "^2.2.0",
3456
"fsm-as-promised": "^0.13.0",
35-
"fullcube-logger": "git+https://github.com/fullcube/fullcube-logger.git",
3657
"lodash": "^4.13.1"
58+
},
59+
"peerDependencies": {
60+
"loopback": ">=2.25.0"
61+
},
62+
"optionalDependencies": {
63+
"loopback-component-explorer": "2.5.0"
3764
}
3865
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const FcSubscription = require('../providers/subscription')
22

33
module.exports = function SubscriptionModel(Subscription) {
4-
// Subscription.observe('fsm:oncancel', ctx => new FcSubscription(ctx.instance).cancel().then(() => ctx))
5-
//
6-
// Subscription.observe('fsm:onreactivate', ctx => new FcSubscription(ctx.instance).reactivate().then(() => ctx))
7-
//
8-
// Subscription.observe('fsm:onexpire', ctx => new FcSubscription(ctx.instance).expire().then(() => ctx))
4+
Subscription.observe('fsm:oncancel', ctx => new FcSubscription(ctx.instance).cancel().then(() => ctx))
5+
6+
Subscription.observe('fsm:onreactivate', ctx => new FcSubscription(ctx.instance).reactivate().then(() => ctx))
7+
8+
Subscription.observe('fsm:onexpire', ctx => new FcSubscription(ctx.instance).expire().then(() => ctx))
99
}

test/fullcube-state-machine/common/providers/membership.js

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
const Promise = require('bluebird')
2-
const log = require('fullcube-logger')
2+
const log = require('loglevel')
3+
4+
log.enableAll()
35

46
module.exports = class FcSubscription {
57
constructor(instance) {
6-
this.provider = instance.provider
8+
this.instance = instance
79
}
8-
910
activate() {
10-
return Promise.delay(5000).then(() => {
11-
log.info('subscription activated')
11+
return Promise.delay(2000).then(() => {
12+
log.info(`Subscription ${this.instance.id} activated`)
1213
})
1314
}
1415

1516
cancel() {
16-
return Promise.delay(5000).then(() => {
17-
log.info('subscription canceled')
17+
return Promise.delay(2000).then(() => {
18+
log.info(`Subscription ${this.instance.id} canceled`)
1819
})
1920
}
2021

2122
reactivate() {
22-
return Promise.delay(5000).then(() => {
23-
log.info('subscription reactivated')
23+
return Promise.delay(2000).then(() => {
24+
log.info(`Subscription ${this.instance.id} reactivated`)
2425
})
2526
}
2627

2728
expire() {
28-
return Promise.delay(5000).then(() => {
29-
log.info('subscription expired')
29+
return Promise.delay(2000).then(() => {
30+
log.info(`Subscription ${this.instance.id} expired`)
3031
})
3132
}
3233
}

0 commit comments

Comments
 (0)