diff --git a/package.json b/package.json index 7623009..a86affc 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "evalmd": "^0.0.19", "foreach": "^2.0.5", "functions-have-names": "^1.2.2", + "mock-property": "^1.0.0", "nyc": "^10.3.2", "object-inspect": "^1.12.0", "object.assign": "^4.1.2", diff --git a/test/shimmed.js b/test/shimmed.js index 8da8de9..da2b0a5 100644 --- a/test/shimmed.js +++ b/test/shimmed.js @@ -8,6 +8,8 @@ var test = require('tape'); var defineProperties = require('define-properties'); var callBind = require('call-bind'); var hasSymbols = require('has-symbols')(); +var mockProperty = require('mock-property'); + var regexMatchAll = require('../regexp-matchall'); var isEnumerable = Object.prototype.propertyIsEnumerable; @@ -43,23 +45,16 @@ test('shimmed', function (t) { }); st.test('no symbol present', function (s2t) { - var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, Symbol.matchAll); - s2t.doesNotThrow(function () { 'abc'.matchAll('b'); }, 'does not throw on string input, with the symbol on regex prototype'); - // eslint-disable-next-line no-extend-native - Object.defineProperty(RegExp.prototype, Symbol.matchAll, { - configurable: true, - enumerable: false, + s2t.teardown(mockProperty(RegExp.prototype, Symbol.matchAll, { + nonEnumerable: true, value: undefined, - writable: true - }); + nonWritable: false + })); s2t['throws'](function () { 'abc'.matchAll('b'); }, 'throws on string input, without the symbol on regex prototype'); - // eslint-disable-next-line no-extend-native - Object.defineProperty(RegExp.prototype, Symbol.matchAll, desc); - s2t.end(); });