Skip to content

Commit e1c123c

Browse files
committed
single process
1 parent 9cf4879 commit e1c123c

File tree

6 files changed

+29
-1
lines changed

6 files changed

+29
-1
lines changed

abc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var a = 1;
2+
var b = 1;
3+
if ((a + b) > 2) {
4+
console.log('more than two');
5+
}

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = function (config) {
4646
//'PhantomJS',
4747
//'Edge',
4848
],
49-
singleRun: false,
49+
singleRun: true,
5050
concurrency: Infinity
5151
})
5252
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"karma": "npm run build && karma start",
1111
"push": "git add ./ && git commit && git pull && git push",
1212
"deploy": "npm run build && npm run push && npm publish",
13+
"cover": "istanbul cover _mocha test/test.sqrt.js",
1314
"build/webpack": "cross-env NODE_ENV=prod webpack --env.foo=bar --profile --progress --config ./build/webpack.config.js"
1415
},
1516
"repository": {

sqrt.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var My = {
2+
sqrt: function (x) {
3+
return x * x
4+
}
5+
}
6+
module.exports = My

test/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,4 @@ describe('extension', function () {
263263
})
264264
})
265265

266+
// chai驗證是否有正確地拋異常

test/test.sqrt.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var chai = require('chai')
2+
var expect = chai.expect
3+
var My = require('../sqrt.js')
4+
5+
describe("sqrt", function() {
6+
7+
it("4的平方根应该等于2", function() {
8+
expect(My.sqrt(4)).to.equal(16)
9+
})
10+
11+
it("参数为负值时应该报错", function() {
12+
expect(function(){ My.sqrt(-1) }).to.equal(1)
13+
})
14+
15+
})

0 commit comments

Comments
 (0)