From 1d7b6e6a2aef4bc50448ba5b2d5f818337948b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Mon, 1 Mar 2021 05:42:30 +0100 Subject: [PATCH] Create hello-there_test.js --- js/tests/hello-there_test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 js/tests/hello-there_test.js diff --git a/js/tests/hello-there_test.js b/js/tests/hello-there_test.js new file mode 100644 index 00000000..2647a547 --- /dev/null +++ b/js/tests/hello-there_test.js @@ -0,0 +1,20 @@ +import { readFileSync as read } from 'fs' + +// /*/ // ⚡ +export const tests = [ + ({ eq }) => // code must use console.log + read('/jail/student/hello-there.js', 'utf8').trim().includes('console.log'), + + async ({ eq, ctx }) => { + // console.log must have been called with the right value + const log = console.log.bind(console) + const args = [] + console.log = (..._args) => { + args.push(..._args) + log(..._args) + } + await import('/jail/student/hello-there.js') + console.log = log + eq(ctx.args.join(' ').trim(), 'Hello There') + }, +]