Changeset 79a0317 for imaps-frontend/node_modules/is-regex/test
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/is-regex/test/index.js
r0c6b92a r79a0317 2 2 3 3 var hasToStringTag = require('has-tostringtag/shams')(); 4 var forEach = require('for each');4 var forEach = require('for-each'); 5 5 var test = require('tape'); 6 6 var isRegex = require('..'); 7 7 8 8 test('not regexes', function (t) { 9 // @ts-expect-error 9 10 t.notOk(isRegex(), 'undefined is not regex'); 10 11 t.notOk(isRegex(null), 'null is not regex'); … … 21 22 test('@@toStringTag', { skip: !hasToStringTag }, function (t) { 22 23 var regex = /a/g; 24 /** @type {{ toString(): string, valueOf(): RegExp, [Symbol.toStringTag]?: string}} */ 23 25 var fakeRegex = { 24 26 toString: function () { return String(regex); }, … … 40 42 var regex = /a/; 41 43 var marker = {}; 44 // @ts-expect-error 42 45 regex.lastIndex = marker; 43 46 st.equal(regex.lastIndex, marker, 'lastIndex is the marker object'); … … 60 63 61 64 test('does not perform operations observable to Proxies', { skip: typeof Proxy !== 'function' }, function (t) { 62 var Handler = function () { 65 /** @constructor */ 66 function Handler() { 67 /** @type (keyof Reflect)[]} */ 63 68 this.trapCalls = []; 64 } ;69 } 65 70 66 forEach([ 71 // eslint-disable-next-line no-extra-parens 72 forEach(/** @const @type {(keyof Reflect)[]} */ ([ 67 73 'defineProperty', 68 74 'deleteProperty', … … 76 82 'set', 77 83 'setPrototypeOf' 78 ] , function (trapName) {84 ]), function (trapName) { 79 85 Handler.prototype[trapName] = function () { 80 86 this.trapCalls.push(trapName); 87 // @ts-expect-error TODO: not sure why this is erroring 81 88 return Reflect[trapName].apply(Reflect, arguments); 82 89 }; … … 85 92 t.test('proxy of object', function (st) { 86 93 var handler = new Handler(); 94 // @ts-expect-error Proxy handlers can be any object 87 95 var proxy = new Proxy({ lastIndex: 0 }, handler); 88 96 89 97 st.equal(isRegex(proxy), false, 'proxy of plain object is not regex'); 90 st.deepEqual(handler.trapCalls, ['getOwnPropertyDescriptor'], 'no unexpected proxy traps were triggered'); 98 st.deepEqual( 99 handler.trapCalls, 100 handler.trapCalls.length > 0 ? ['getOwnPropertyDescriptor'] : [], 101 'no unexpected proxy traps were triggered' 102 ); 91 103 st.end(); 92 104 }); … … 94 106 t.test('proxy of RegExp instance', function (st) { 95 107 var handler = new Handler(); 108 // @ts-expect-error Proxy handlers can be any object 96 109 var proxy = new Proxy(/a/, handler); 97 110 98 111 st.equal(isRegex(proxy), false, 'proxy of RegExp instance is not regex'); 99 st.deepEqual(handler.trapCalls, ['getOwnPropertyDescriptor'], 'no unexpected proxy traps were triggered'); 112 st.deepEqual( 113 handler.trapCalls, 114 handler.trapCalls.length > 0 ? ['getOwnPropertyDescriptor'] : [], 115 'no unexpected proxy traps were triggered' 116 ); 100 117 st.end(); 101 118 });
Note:
See TracChangeset
for help on using the changeset viewer.