Browse Source

fix: use url encoded code in hello-there test

pull/745/head
Clement Denis 4 years ago
parent
commit
e15419eacc
  1. 9
      js/tests/hello-there_test.js

9
js/tests/hello-there_test.js

@ -5,7 +5,7 @@ export const tests = [
({ eq }) => // code must use console.log ({ eq }) => // code must use console.log
read('/jail/student/hello-there.js', 'utf8').trim().includes('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 // console.log must have been called with the right value
const log = console.log.bind(console) const log = console.log.bind(console)
const args = [] const args = []
@ -13,8 +13,11 @@ export const tests = [
args.push(..._args) args.push(..._args)
log(..._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 console.log = log
eq(ctx.args.join(' ').trim(), 'Hello There') eq(args.join(' ').trim(), 'Hello There')
}, },
] ]

Loading…
Cancel
Save