Skip to content

Commit

Permalink
skipWhile tests improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Keloo committed Aug 9, 2018
1 parent 87032b9 commit d248b3e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/iterators/skipWhile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,30 @@ describe('iterators/skipWhile', () => {
expect(toArray(iterator)).to.deep.equal([]);
});
});

describe('When take elements by index', () => {
it('Should return 3 elements', () => {
const source = [1, 2, 3, 4, 5, 5, 5];
const iterator = skipWhile(source, (e, idx) => idx <= 3);

expect(toArray(iterator)).to.deep.equal([5, 5, 5]);
});
});

describe('When take elements by object property', () => {
it('Should return 2 elements', () => {
const source = [
{ val: 1 },
{ val: 10 },
{ val: -1 },
{ val: -2 },
];
const iterator = skipWhile(source, e => e.val > 0);

expect(toArray(iterator)).to.deep.equal([
{ val: -1 },
{ val: -2 },
]);
});
});
});

0 comments on commit d248b3e

Please sign in to comment.