This repository has been archived by the owner on Nov 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* code cleanup * fixed takeWhile to return correct results * fixed skipWhile to return correct results * fixed skip to return the proper results * increased test coverage * Update package.json
- Loading branch information
Gerald Burkholder
authored
Dec 3, 2017
1 parent
ebcdc5f
commit a8ce657
Showing
27 changed files
with
383 additions
and
180 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var Enumerable = require('../src/enumerable'); | ||
|
||
describe("Enumerable", function () | ||
{ | ||
describe("when initialized from an empty array", function () | ||
{ | ||
it("should return an empty enumerable object", function () | ||
{ | ||
var testArray = []; | ||
|
||
var result = new Enumerable(testArray); | ||
|
||
expect(result).toEqual(new Enumerable([])); | ||
}); | ||
}); | ||
|
||
describe("when initialized from a null array", function () | ||
{ | ||
it("should return an empty enumerable object", function () | ||
{ | ||
var testArray = null; | ||
|
||
var result = new Enumerable(testArray); | ||
|
||
expect(result).toEqual(new Enumerable([])); | ||
}); | ||
}); | ||
}); |
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,52 @@ | ||
var Enumerable = require('../src/enumerable'); | ||
|
||
describe("skip", function () | ||
{ | ||
describe("when an enumerable object has 3 items", function () | ||
{ | ||
it("should skip specified number of items and return the remaining items", function () | ||
{ | ||
var testArray = new Enumerable([{ name: 'test', id: 1 }, { name: '1234', id: 2 }, { name: '5678', id: 3 }]); | ||
|
||
var result = testArray.skip(2); | ||
|
||
expect(result).toEqual(new Enumerable([{ name: '5678', id: 3 }])); | ||
}); | ||
}); | ||
|
||
describe("when an enumerable object has multiple items", function () | ||
{ | ||
it("should skip specified number of items and return the remaining items", function () | ||
{ | ||
var testArray = new Enumerable([98, 92, 85, 82, 70, 59, 56]); | ||
|
||
var result = testArray.skip(3); | ||
|
||
expect(result).toEqual(new Enumerable([82, 70, 59, 56])); | ||
}); | ||
}); | ||
|
||
describe("when an enumerable object is empty", function () | ||
{ | ||
it("should return empty enumerable", function () | ||
{ | ||
var testArray = new Enumerable([]); | ||
|
||
var result = testArray.skip(2); | ||
|
||
expect(result).toEqual(new Enumerable([])); | ||
}); | ||
}); | ||
|
||
describe("when count is a greater integer than the length of the enumerable object", function () | ||
{ | ||
it("should return current enumerable", function () | ||
{ | ||
var testArray = new Enumerable([{ name: 'test', id: 1 }, { name: '1234', id: 2 }, { name: '5678', id: 3 }]); | ||
|
||
var result = testArray.skip(50); | ||
|
||
expect(result).toEqual(testArray); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.