Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
chore: add tests for lib files
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimr committed Nov 5, 2016
1 parent 0bbf932 commit 30bbe29
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ before_script:
- npm install -g grunt-cli

script:
- npm run test:lib
- grunt
2 changes: 1 addition & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function (grunt) {
eslint: {
target: [
'<%= files.adapter %>',
'gruntfile.js',
'*.js',
'lib/index.js',
'tasks/*.js',
'test/**/*.js'
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function (config) {

files: [
'src/*.js',
'test/*.js'
'test/src/*.js'
],

browsers: process.env.TRAVIS ? ['Firefox'] : ['Chrome'],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"gitattributes": ".gitattributes"
},
"scripts": {
"test": "grunt test"
"test": "grunt test",
"test:lib": "mocha test/lib"
},
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions test/lib/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"mocha": true
}
}
42 changes: 42 additions & 0 deletions test/lib/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
var expect = require('chai').expect
var initMocha = require('../../lib')['framework:mocha'][1]

describe('framework:mocha', function () {
var files

beforeEach(function () {
files = createMockFiles()
})

it('should add adapter.js', function () {
initMocha(files)

expect(files[1].pattern).to.contain('adapter.js')
})

it('should add mocha.js', function () {
initMocha(files)

expect(files[0].pattern).to.contain('mocha.js')
})

it('should add required files', function () {
var mochaConfig = {require: ['foo.js']}

initMocha(files, mochaConfig)

expect(files[1].pattern).to.contain('foo.js')
})

it('should add mocha.css if we define reporter in config', function () {
var mochaConfig = {reporter: 'html'}

initMocha(files, mochaConfig)

expect(files[0].pattern).to.contain('mocha.css')
})
})

function createMockFiles () {
return []
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions wallaby.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = function () {
return {
files: [
'lib/**/*@(.js)'
],

tests: [
'./test/lib/**/*.spec@(.js)'
],

env: {
type: 'node'
},

testFramework: 'mocha'
}
}

0 comments on commit 30bbe29

Please sign in to comment.