Browse Source

test(declarations): Add new tests to check if variables are constat

pull/1420/head
nprimo 2 years ago committed by Niccolò Primo
parent
commit
ec55a11e80
  1. 12
      js/tests/declarations_test.js

12
js/tests/declarations_test.js

@ -1,5 +1,13 @@
export const tests = []
const t = (f) => tests.push(f)
const isConst = (name) => {
try {
eval(`${name} = 'm'`)
return false
} catch (err) {
return true
}
}
// escapeStr
// is declared and of type string
@ -72,4 +80,8 @@ t(() => nested.obj.update === undefined)
t(() => cantEdit(() => nested.arr.push('hot stuff')))
t(() => nested.arr.length === 3)
// check if all variable are const
t(() => ['escapeStr', 'arr', 'obj', 'nested']
.every(isConst))
Object.freeze(tests)

Loading…
Cancel
Save