jai shree ram
This commit is contained in:
67
node_modules/es-shim-unscopables/test/index.js
generated
vendored
Normal file
67
node_modules/es-shim-unscopables/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var inspect = require('object-inspect');
|
||||
var v = require('es-value-fixtures');
|
||||
var forEach = require('for-each');
|
||||
var has = require('has');
|
||||
|
||||
var shimUnscopables = require('../');
|
||||
|
||||
var sortSymbols = function (a, b) {
|
||||
return inspect(a).localeCompare(inspect(b));
|
||||
};
|
||||
|
||||
test('shimUnscopables', function (t) {
|
||||
t.equal(typeof shimUnscopables, 'function', 'is a function');
|
||||
|
||||
forEach(v.nonStrings, function (notNonEmptyString) {
|
||||
t['throws'](
|
||||
function () { shimUnscopables(notNonEmptyString); },
|
||||
TypeError,
|
||||
inspect(notNonEmptyString) + ' is not a non-empty String'
|
||||
);
|
||||
});
|
||||
|
||||
t['throws'](
|
||||
function () { shimUnscopables('x'); },
|
||||
TypeError,
|
||||
inspect('x') + ' is not on Array.prototype'
|
||||
);
|
||||
|
||||
t.test('no symbols', { skip: typeof Symbol === 'function' }, function (st) {
|
||||
st.doesNotThrow(function () { shimUnscopables('forEach'); });
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('symbols, no unscopables', { skip: typeof Symbol !== 'function' || Symbol.unscopables }, function (st) {
|
||||
st.deepEqual(Object.getOwnPropertySymbols(Array.prototype), [Symbol.iterator]);
|
||||
|
||||
shimUnscopables('forEach');
|
||||
|
||||
st.deepEqual(Object.getOwnPropertySymbols(Array.prototype), [Symbol.iterator]);
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('Symbol.unscopables', { skip: typeof Symbol !== 'function' || !Symbol.unscopables }, function (st) {
|
||||
st.deepEqual(
|
||||
Object.getOwnPropertySymbols(Array.prototype).sort(sortSymbols),
|
||||
[Symbol.iterator, Symbol.unscopables]
|
||||
);
|
||||
st.notOk(has(Array.prototype[Symbol.unscopables], 'forEach'), 'unscopables map lacks forEach');
|
||||
|
||||
shimUnscopables('forEach');
|
||||
|
||||
st.deepEqual(
|
||||
Object.getOwnPropertySymbols(Array.prototype).sort(sortSymbols),
|
||||
[Symbol.iterator, Symbol.unscopables]
|
||||
);
|
||||
st.equal(Array.prototype[Symbol.unscopables].forEach, true, 'unscopables map has forEach');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
35
node_modules/es-shim-unscopables/test/with.js
generated
vendored
Normal file
35
node_modules/es-shim-unscopables/test/with.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/* eslint no-restricted-syntax: 0, no-with: 0, strict: 0 */
|
||||
|
||||
var test = require('tape');
|
||||
|
||||
var shimUnscopables = require('../');
|
||||
|
||||
test('`with` statement', { skip: typeof Symbol !== 'function' || !Symbol.unscopables }, function (t) {
|
||||
var entries;
|
||||
var concat;
|
||||
with ([]) {
|
||||
t.equal(concat, Array.prototype.concat, 'concat is dynamically bound');
|
||||
t.notEqual(entries, Array.prototype.entries, 'entries is not dynamically bound');
|
||||
}
|
||||
|
||||
var obj = {
|
||||
foo: 1,
|
||||
bar: 2
|
||||
};
|
||||
var foo;
|
||||
var bar;
|
||||
obj[Symbol.unscopables] = { foo: true };
|
||||
with (obj) {
|
||||
t.equal(foo, undefined);
|
||||
t.equal(bar, obj.bar);
|
||||
}
|
||||
|
||||
shimUnscopables('concat');
|
||||
|
||||
with ([]) {
|
||||
t.notEqual(concat, Array.prototype.concat, 'concat is no longer dynamically bound');
|
||||
t.notEqual(entries, Array.prototype.entries, 'entries is still not dynamically bound');
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
Reference in New Issue
Block a user