Browse Source

add tests

tags/v0.4.0
glmdev 8 months ago
parent
commit
b77823bd42
4 changed files with 1375 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. 8
    0
      package.json
  3. 57
    0
      test/test.js
  4. 1309
    0
      yarn.lock

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
node_modules/*

+ 8
- 0
package.json View File

@@ -13,9 +13,17 @@
"glmdev",
"express"
],
"scripts": {
"test": "mocha"
},
"author": "Garrett Mills <garrett@glmdev.tech> (https://glmdev.tech/)",
"license": "MIT",
"dependencies": {
"express-less": "^0.1.0"
},
"devDependencies": {
"mocha": "^6.1.3",
"chai": "^4.2.0",
"sinon": "^7.3.1"
}
}

+ 57
- 0
test/test.js View File

@@ -0,0 +1,57 @@
const expect = require('chai').expect
const sinon = require('sinon')
const dir = __dirname

describe('flitter-less LessUnit', function(){
describe('express-less init', function() {
let unit, test_app

beforeEach(function () {
unit = new (require('../LessUnit'))(dir)

function use(key, value) {
this.bound[key] = value
}

test_app = {
bound: {},
express: {}
}

test_app.express.use = use.bind(test_app)

unit.go(test_app)
})

it('should return a function()', function () {
expect(test_app.bound['/style-asset']).to.be.a('function')
})

it('should take 3 arguments', function () {
expect(test_app.bound['/style-asset'].length).to.equal(3)
})
})
describe('express-less handler test call', function(){
it('should call next() once', function(){
let unit = new (require('../LessUnit'))(dir)
let test_app = {
bound: {},
express: {},
}
function use(key, value){
this.bound[key] = value
}
test_app.express.use = use.bind(test_app)
unit.go(test_app)
let next_spy = sinon.spy()
test_app.bound['/style-asset']({}, {}, next_spy)
expect(next_spy.calledOnce).to.be.true
})
})
})

+ 1309
- 0
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save