Last active
December 24, 2019 12:08
-
-
Save automagisch/21ecf832ff2996d83ef7551f9ceb4c2c to your computer and use it in GitHub Desktop.
Placeholder tests for npm package when you haven't written any yet and are not planning to do that for a longer time. Let's play 'Tests Against Humanity'
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
/** Tests against humanity v1 | |
* 1. add this file to something like `{project}/tests/test.js` | |
* 2. add command `node tests/test.js` to package.json.scripts under the key "test" | |
* 3. run `npm test` | |
*/ | |
const { log } = console; | |
const lameExcuses = [ | |
"I guess it's allright-ish. Just do not take my word for it.", | |
"Test aborted due to quantum interpolations in the 4th dimensional sphere", | |
"No, I do not want to.", | |
"Hello, this is my voicemail, please leave a message after the beep-boop.", | |
"I suddenly forgot how to do that.", | |
"Can't you ask Karen? I'm kinda busy right now", | |
"Maximum value reached for motivation. Politely try again later.", | |
"Go f**k yourself." | |
]; | |
const nonErrors = [ | |
"Uncaught MotivationError", | |
"Raised MehError", | |
"Expected PersonalSpaceError", | |
] | |
const stagedScenarios = [ | |
(result, err) => { | |
log('\n[telemetry establised]\n'); | |
setTimeout(() => { | |
setTimeout(() => log('\n...'), 500); | |
setTimeout(() => log('\nbeep'), 3000); | |
setTimeout(() => log('\n{computer noises}'), 5000); | |
setTimeout(() => log('\n{screams in binary}'), 7000); | |
setTimeout(() => log('\nboop'), 9000); | |
setTimeout(() => { | |
log(`\n${err}: ${result}`); | |
log('\n[telemetry lost]\n'); | |
}, 10000); | |
}, 1000); | |
}, | |
(result, err) => { | |
log('\nWell...\n'); | |
setTimeout(() => log('\n...\n'), 1000); | |
setTimeout(() => log(result), 1000); | |
}, | |
(result, err) => { | |
log('\n...\n'); | |
setTimeout(() => log(`${err}: ${result}`), 1500); | |
} | |
]; | |
const outcome = lameExcuses[Math.floor(Math.random() * lameExcuses.length)]; | |
const stagedScenario = stagedScenarios[Math.floor(Math.random() * stagedScenarios.length)] | |
const nonError = nonErrors[Math.floor(Math.random() * nonErrors.length)]; | |
stagedScenario(outcome, nonError); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment