Last active
July 23, 2017 10:39
-
-
Save koresar/f246399b19f6de4b9786f990e18ef8e1 to your computer and use it in GitHub Desktop.
Fun with Stamps. Episode 17. Easy 100% unit test coverage in JS: - app2-test1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('express app setup', () => { | |
const http = { | |
createServer() { | |
return {on() {}, listen() {}}; | |
} | |
}; | |
const App = require('../app2').props({http}); | |
it('should share ./public', (done) => { | |
const express = () => ({set() {}, use() {}}); | |
express.static = (path) => { | |
if (path.endsWith('/public')) { | |
done(); | |
} | |
}; | |
const MockedApp = App.props({express}); | |
MockedApp(); | |
}); | |
it('should not share non ./public', () => { | |
const express = () => ({set() {}, use() {}}); | |
express.static = (path) => { | |
if (!path.endsWith('/public')) { | |
throw new Error('Should not share non public files'); | |
} | |
}; | |
const MockedApp = App.props({express}); | |
MockedApp(); | |
}); | |
it('should set urlencoded external=false', (done) => { | |
const bodyParser = { | |
json() { return () => {}; }, | |
urlencoded({extended}) { | |
if (extended !== false) { | |
throw new Error('urlencoded extended option must be false'); | |
} | |
done(); | |
return () => {}; | |
} | |
}; | |
const MockedApp = App.props({bodyParser}); | |
MockedApp(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment