diff --git a/js/tests/declarations_test.js b/js/tests/declarations_test.js index 53d1ed9a..26dfc78a 100644 --- a/js/tests/declarations_test.js +++ b/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)