From 460dfd1eb65cff2935fae460a6c71b0171b226c7 Mon Sep 17 00:00:00 2001 From: Johannes Ewald Date: Tue, 24 Apr 2018 13:29:51 +0200 Subject: Fix const regex Fixes an issue where const wasn't properly detected when using destructering. --- testLib/constModule.js | 4 ++++ testLib/sharedTestCases.js | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'testLib') diff --git a/testLib/constModule.js b/testLib/constModule.js index efff495..360a0f5 100644 --- a/testLib/constModule.js +++ b/testLib/constModule.js @@ -9,6 +9,7 @@ const g = "g"; const/*wtf this is valid*/h = "h"; const /*and this is also*/i = "i"; +const{k} = {k: "k"}; exports.a = function () { return a; @@ -40,3 +41,6 @@ exports.i = function () { exports.j = function () { return j; }; +exports.k = function () { + return k; +}; diff --git a/testLib/sharedTestCases.js b/testLib/sharedTestCases.js index 6cd9b2e..9b709c2 100644 --- a/testLib/sharedTestCases.js +++ b/testLib/sharedTestCases.js @@ -388,10 +388,13 @@ module.exports = function () { it("should be possible to set a const variable", function () { var constModule = rewire("./constModule"); + var varNames = Object.keys(constModule); - "abcdefghij".split("").forEach(letter => { - constModule.__set__(letter, "this has been changed"); // should not throw - expect(constModule[letter]()).to.equal("this has been changed"); + expect(varNames.length).to.be.greaterThan(0); + + varNames.forEach(varName => { + constModule.__set__(varName, "this has been changed"); // should not throw + expect(constModule[varName]()).to.equal("this has been changed"); }); }); -- cgit v1.2.3