Skip to content

Commit

Permalink
move tests which don't require Symbol outside of the symbol if block
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeChampion committed Apr 5, 2020
1 parent c077914 commit 50dc255
Showing 1 changed file with 42 additions and 40 deletions.
82 changes: 42 additions & 40 deletions polyfills/Object/fromEntries/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,54 +39,56 @@ it('throws when an entry object is absent', function () {
}, TypeError);
});

if('Symbol' in self && 'iterator' in self.Symbol && !!Array.prototype[Symbol.iterator]) {
it('returns empty object if given an empty array', function () {
proclaim.deepStrictEqual(Object.fromEntries([]), {});
});

if ('getOwnPropertyDescriptor' in Object) {
it('Creates data properties which are enumerable, writable, and configurable', function () {
var result = Object.fromEntries([
['key', 'value']
]);
proclaim.deepStrictEqual(Object.getOwnPropertyDescriptor(result, "key"), {
value: 'value',
enumerable: true,
writable: true,
configurable: true
});
it('returns empty object if given an empty array', function () {
proclaim.deepStrictEqual(Object.fromEntries([]), {});
});

if ('getOwnPropertyDescriptor' in Object) {
it('Creates data properties which are enumerable, writable, and configurable', function () {
var result = Object.fromEntries([
['key', 'value']
]);
proclaim.deepStrictEqual(Object.getOwnPropertyDescriptor(result, "key"), {
value: 'value',
enumerable: true,
writable: true,
configurable: true
});
}

it('succeeds when an entry object is a boxed Object', function () {
proclaim.deepStrictEqual(Object.fromEntries([Object('ab')]).a, 'b');
});

it('succeeds when an entry object is a boxed String', function () {
proclaim.deepStrictEqual(Object.fromEntries([new String('ab')]).a, 'b');
}

it('succeeds when an entry object is a boxed Object', function () {
proclaim.deepStrictEqual(Object.fromEntries([Object('ab')]).a, 'b');
});

it('succeeds when an entry object is a boxed String', function () {
proclaim.deepStrictEqual(Object.fromEntries([new String('ab')]).a, 'b');
});

it('works with expected input', function () {
var a = {};
var b = {};
var c = {};
var entries = [
['a', a],
['b', b],
['c', c]
];

proclaim.deepStrictEqual(Object.fromEntries(entries), {
a: a,
b: b,
c: c
});
});

if('Symbol' in self && 'iterator' in self.Symbol && !!Array.prototype[Symbol.iterator]) {
it('works with Symbols', function () {
var key = Symbol();
var result = Object.fromEntries([
[key, 'value']
]);
proclaim.deepStrictEqual(result[key], 'value');
});

it('works with expected input', function () {
var a = {};
var b = {};
var c = {};
var entries = [
['a', a],
['b', b],
['c', c]
];

proclaim.deepStrictEqual(Object.fromEntries(entries), {
a: a,
b: b,
c: c
});
});

}

0 comments on commit 50dc255

Please sign in to comment.