mirror of https://github.com/01-edu/public.git
test(declarations): Add new tests to check if variables are constat
This commit is contained in:
parent
e52e60a612
commit
ec55a11e80
|
@ -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…
Reference in New Issue