Skip to content

Commit 052e6bd

Browse files
committed
[test] Switch test file into coffeescript
1 parent 1fcadef commit 052e6bd

File tree

3 files changed

+60
-73
lines changed

3 files changed

+60
-73
lines changed

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,19 @@
2727
"colors": "1.0.3"
2828
},
2929
"devDependencies": {
30-
"mocha": "2.0.0",
3130
"chai": "1.10.0",
3231
"chai-as-promised": "4.1.1",
32+
"coffee-script": "^1.8.0",
3333
"grunt": "0.4.5",
3434
"grunt-contrib-jshint": "0.10.0",
35-
"grunt-istanbul-coverage": "0.0.5",
35+
"grunt-exec": "0.4.6",
3636
"grunt-istanbul": "0.2.4",
37-
"grunt-exec": "0.4.6"
37+
"grunt-istanbul-coverage": "0.0.5",
38+
"mocha": "2.0.0"
3839
},
3940
"scripts": {
40-
"test": "mocha",
41+
"test": "mocha --compilers coffee:coffee-script/register",
42+
"test-watch": "mocha -w --compilers coffee:coffee-script/register",
4143
"istanbul": "istanbul cover _mocha test/*.js"
4244
}
4345
}

test/index.coffee

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#global describe:true, it:false, beforeEach:false
2+
3+
#jshint -W030
4+
chai = require('chai')
5+
chaiAsPromised = require('chai-as-promised')
6+
expect = chai.expect
7+
Promise = require('bluebird')
8+
scanner = require('../index')
9+
10+
chai.use chaiAsPromised
11+
12+
13+
treePath = 'test/tree'
14+
treePathWithoutJSFile = treePath + '/withoutjs'
15+
treePathComplex = treePath + '/complex'
16+
treePathCrash = '/crash'
17+
treePathNotExisting = '/doesntexist'
18+
19+
expectedComplexRes = require('./complex-tree-results')
20+
expectedSkipRes = require('./skip-results')
21+
expectedEmptyRes =
22+
report: []
23+
fails: [
24+
ref: 'test/tree/withoutjs/stuff'
25+
message: 'not a valid file'
26+
]
27+
28+
29+
describe 'the complexity scanner', ->
30+
31+
it 'should return a Promise', ->
32+
expect(scanner(treePath)).to.be.an.instanceof Promise
33+
34+
35+
describe 'the complexity scanner promise', ->
36+
37+
it 'should return an empty array when targeted folder doesn\'t contain .js files', (done) ->
38+
39+
expect(scanner(treePathWithoutJSFile)).to.be.fulfilled.and.to.eventually.deep.equal(expectedEmptyRes).and.notify done
40+
41+
42+
it 'should return the attended complex result', (done) ->
43+
44+
@timeout 10000
45+
expect(scanner(treePathComplex)).to.eventually.deep.equal(expectedComplexRes).to.be.fulfilled.and.notify done
46+
47+
48+
it 'should return the attended complex result when a skip folder path is passed', (done) ->
49+
50+
@timeout 10000
51+
expect(scanner(treePathComplex, ['/tree/complex/jquery'])).to.eventually.deep.equal(expectedSkipRes).to.be.fulfilled.and.notify done
52+
53+
54+

test/index.js

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)