-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
4,758 additions
and
5,820 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ node_modules/ | |
lib/ | ||
reports/ | ||
docs/ | ||
.nyc_output/ | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"all": true, | ||
"check-coverage": false, | ||
"reporter": ["text-summary", "text", "html", "json"], | ||
"lines": 86, | ||
"statements": 85.93, | ||
"functions": 82.43, | ||
"branches": 76.06, | ||
"exclude": [ | ||
"coverage", | ||
"test" | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,45 @@ | ||
/* eslint-env mocha */ | ||
import expect from 'expect'; | ||
import test from 'tape'; | ||
import values from 'object.values'; | ||
import mockProperty from 'mock-property'; | ||
|
||
import iterationDecorator from '../../../src/util/iterationDecorator'; | ||
|
||
describe('iterationDecorator', function () { | ||
describe('should add a Symbol.iterator property to a collection', function () { | ||
it('should return the values when iterated', function () { | ||
test('iterationDecorator', (t) => { | ||
t.test('adds a Symbol.iterator property to a collection', async (st) => { | ||
// const collection = {a: 'apple', b: 'banana', c: 'cantaloupe'}; | ||
const collection = { | ||
'a': 'apple', | ||
'b': 'banana', | ||
'c': 'cantaloupe', | ||
}; | ||
const arr = ['apple', 'banana', 'cantaloupe']; | ||
const iter = iterationDecorator(collection, Object.values(collection)); | ||
expect([...iter]).toEqual(expect.arrayContaining(arr)); | ||
}); | ||
const iter = iterationDecorator(collection, values(collection)); | ||
st.deepEqual([...iter], arr, 'returns the values when iterated'); | ||
}); | ||
describe('when Symbol is not defined in the global space', function () { | ||
beforeEach(function () { | ||
global.originalSymbol = global.Symbol | ||
global.originalSymbolIterator = global.Symbol.iterator; | ||
global.Symbol = undefined; | ||
}); | ||
it('should not add a Symbol.iterator property to a collection', function () { | ||
const collection = { | ||
'a': 'apple', | ||
'b': 'banana', | ||
'c': 'cantaloupe', | ||
}; | ||
const iter = iterationDecorator(collection, []); | ||
expect(iter[global.originalSymbolIterator]).not.toBeDefined(); | ||
}); | ||
afterEach(function () { | ||
global.Symbol = global.originalSymbol; | ||
global.originalSymbol = undefined; | ||
global.originalSymbolIterator = undefined; | ||
}); | ||
|
||
t.test('when Symbol is not defined in the global space', async (st) => { | ||
const originalSymbolIterator = typeof Symbol === 'function' ? Symbol.iterator : null; | ||
st.teardown(mockProperty(global, 'Symbol', { value: undefined })); | ||
|
||
const collection = { | ||
'a': 'apple', | ||
'b': 'banana', | ||
'c': 'cantaloupe', | ||
}; | ||
const iter = iterationDecorator(collection, []); | ||
st.equal(iter[originalSymbolIterator], undefined, 'does not add a Symbol.iterator property to a collection'); | ||
}); | ||
describe('when Symbol.iterator is not defined in the global space', function () { | ||
beforeEach(function () { | ||
global.originalSymbol = global.Symbol | ||
global.originalSymbolIterator = global.Symbol.iterator; | ||
global.Symbol = function () {}; | ||
}); | ||
it('should not add a Symbol.iterator property to a collection', function () { | ||
const collection = { | ||
'a': 'apple', | ||
'b': 'banana', | ||
'c': 'cantaloupe', | ||
}; | ||
const iter = iterationDecorator(collection, []); | ||
expect(iter[global.originalSymbolIterator]).not.toBeDefined(); | ||
}); | ||
afterEach(function () { | ||
global.Symbol = global.originalSymbol; | ||
global.originalSymbol = undefined; | ||
global.originalSymbolIterator = undefined; | ||
}); | ||
|
||
t.test('when Symbol.iterator is not defined in the global space', async (st) => { | ||
const originalSymbolIterator = typeof Symbol === 'function' ? Symbol.iterator : null; | ||
st.teardown(mockProperty(global, 'Symbol', { value: function () {} })); | ||
|
||
const collection = { | ||
'a': 'apple', | ||
'b': 'banana', | ||
'c': 'cantaloupe', | ||
}; | ||
const iter = iterationDecorator(collection, []); | ||
st.equal(iter[originalSymbolIterator], undefined, 'does not add a Symbol.iterator property to a collection'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
/* eslint-env mocha */ | ||
import expect from 'expect'; | ||
import test from 'tape'; | ||
|
||
import iteratorProxy from '../../../src/util/iteratorProxy'; | ||
|
||
describe('iteratorProxy', function () { | ||
it('should create an iterator for the bound array', function () { | ||
const arr = ['a', 'b', 'c']; | ||
const iter = { | ||
[Symbol.iterator]: iteratorProxy.bind(arr) | ||
}; | ||
expect([...iter]).toEqual(expect.arrayContaining(arr)); | ||
}); | ||
test('iteratorProxy', async (t) => { | ||
const arr = ['a', 'b', 'c']; | ||
const iter = { | ||
[Symbol.iterator]: iteratorProxy.bind(arr) | ||
}; | ||
|
||
t.deepEqual([...iter], arr, 'creates an iterator for the bound array'); | ||
}); |
Oops, something went wrong.