mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
fix tests
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
For node.js tests
|
||||
|
||||
It forces node.js to load Response (which is loaded lazily)
|
||||
|
||||
Without this, `Response` loading code would be executed in record_io.js and
|
||||
break test by calling `now()`
|
||||
*/
|
||||
globalThis.Response
|
||||
|
||||
export const run = tests => {
|
||||
// Runs test, return failure or null if not failed
|
||||
const run_test = t => {
|
||||
|
||||
@@ -1059,7 +1059,7 @@ export const tests = [
|
||||
'a': 'Object.assign(globalThis, {test_import: true})',
|
||||
})
|
||||
assert_equal(i.active_calltree_node.ok, true)
|
||||
assert_equal(globalThis.test_import, true)
|
||||
assert_equal(globalThis.app_window.test_import, true)
|
||||
}),
|
||||
|
||||
test('modules bare import', () => {
|
||||
@@ -1068,7 +1068,7 @@ export const tests = [
|
||||
'a': 'Object.assign(globalThis, {test_import: true})',
|
||||
})
|
||||
assert_equal(i.active_calltree_node.ok, true)
|
||||
assert_equal(globalThis.test_import, true)
|
||||
assert_equal(globalThis.app_window.test_import, true)
|
||||
}),
|
||||
|
||||
test('bug parser pragma external', () => {
|
||||
|
||||
@@ -11,12 +11,17 @@ Object.assign(globalThis,
|
||||
// for convenince, to type just `log` instead of `console.log`
|
||||
log: console.log,
|
||||
|
||||
// For test env, set globalThis.app_window to just globalThis
|
||||
app_window: globalThis,
|
||||
}
|
||||
)
|
||||
|
||||
export const patch_builtin = new Function(`
|
||||
if(globalThis.process != null ) {
|
||||
globalThis.app_window = globalThis
|
||||
} else {
|
||||
const iframe = globalThis.document.createElement('iframe')
|
||||
globalThis.document.body.appendChild(iframe)
|
||||
globalThis.app_window = iframe.contentWindow
|
||||
}
|
||||
let originals = globalThis.app_window.__builtins_originals
|
||||
let patched = globalThis.app_window.__builtins_patched
|
||||
if(originals == null) {
|
||||
@@ -170,9 +175,9 @@ export const test_deferred_calls_state = code => {
|
||||
|
||||
export const stringify = val =>
|
||||
JSON.stringify(val, (key, value) => {
|
||||
if(value instanceof Set){
|
||||
if(value?.[Symbol.toStringTag] == 'Set'){
|
||||
return [...value]
|
||||
} else if (value instanceof Map) {
|
||||
} else if(value?.[Symbol.toStringTag] == 'Map'){
|
||||
return Object.fromEntries([...value.entries()])
|
||||
} else if(value instanceof Error) {
|
||||
return {message: value.message}
|
||||
|
||||
Reference in New Issue
Block a user