Skip to content

Instantly share code, notes, and snippets.

@vilindberg
Last active December 7, 2018 09:45
Show Gist options
  • Save vilindberg/f1f0196987b3634d13224d3d5b9f8b61 to your computer and use it in GitHub Desktop.
Save vilindberg/f1f0196987b3634d13224d3d5b9f8b61 to your computer and use it in GitHub Desktop.
class Tester {
constructor(app) {
this.app = app
}
test(cases) {
cases.forEach(tc => {
if (app(tc.input) !== tc.output) {
throw new Error()
}
})
}
}
function app(input) {
if (input == '123') {
return '456'
}
return '123'
}
const cases = [{
input: '123',
output: '456'
}, {
input: '234',
output: '123'
}]
const tester = new Tester(app)
tester.test(cases)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment