|
| 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 | + |
0 commit comments