Last active
December 7, 2018 09:45
-
-
Save vilindberg/f1f0196987b3634d13224d3d5b9f8b61 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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