From e15419eacc726bb68dad95ae0ba064d4a0015a6d Mon Sep 17 00:00:00 2001 From: Clement Denis Date: Mon, 1 Mar 2021 12:23:36 +0000 Subject: [PATCH] fix: use url encoded code in hello-there test --- js/tests/hello-there_test.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/tests/hello-there_test.js b/js/tests/hello-there_test.js index 2647a547..c1667f80 100644 --- a/js/tests/hello-there_test.js +++ b/js/tests/hello-there_test.js @@ -5,7 +5,7 @@ export const tests = [ ({ eq }) => // code must use console.log read('/jail/student/hello-there.js', 'utf8').trim().includes('console.log'), - async ({ eq, ctx }) => { + async ({ eq, code }) => { // console.log must have been called with the right value const log = console.log.bind(console) const args = [] @@ -13,8 +13,11 @@ export const tests = [ args.push(..._args) log(..._args) } - await import('/jail/student/hello-there.js') + + const b64 = Buffer.from(code).toString("base64") + const url = `data:text/javascript;base64,${b64}` + await import(url) console.log = log - eq(ctx.args.join(' ').trim(), 'Hello There') + eq(args.join(' ').trim(), 'Hello There') }, ]