Skip to content

Commit

Permalink
fix(specs): fixing tests for single
Browse files Browse the repository at this point in the history
  • Loading branch information
mpodwysocki authored and trxcllnt committed Sep 1, 2020
1 parent c0a3e68 commit 2793801
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions spec/iterable/last-spec.ts
Expand Up @@ -10,13 +10,15 @@ test('Iterable#last no predicate returns first', () => {
});

test('Iterable#last predicate empty returns undefined', () => {
expect(last<number>([], () => true)).toBe(undefined);
expect(
last<number>([], { predicate: () => true })
).toBe(undefined);
});

test('Iterable#last predicate hits returns value', () => {
expect(last([1, 2, 3, 4, 5], (x) => x % 2 === 0)).toBe(4);
expect(last([1, 2, 3, 4, 5], { predicate: (x) => x % 2 === 0 })).toBe(4);
});

test('Iterable#last predicate misses returns undefined', () => {
expect(last([1, 3, 5], (x) => x % 2 === 0)).toBe(undefined);
expect(last([1, 3, 5], { predicate: (x) => x % 2 === 0 })).toBe(undefined);
});
Expand Up @@ -7,12 +7,12 @@ test('Iterable#single no predicate empty returns undefined', () => {
});

test('Iterable#single with predicate empty returns undefined', () => {
const res = single<number>([], () => true);
const res = single<number>([], { predicate: () => true });
expect(res).toBe(undefined);
});

test('Iterable#single predicate miss', () => {
const res = single([42], x => x % 2 !== 0);
const res = single([42], { predicate: (x) => x % 2 !== 0 });
expect(res).toBe(undefined);
});

Expand All @@ -22,7 +22,7 @@ test('Iterable#single no predicate hit', () => {
});

test('Iterable#single predicate hit', () => {
const res = single([42], x => x % 2 === 0);
const res = single([42], { predicate: (x) => x % 2 === 0 });
expect(res).toBe(42);
});

Expand All @@ -31,5 +31,5 @@ test('Iterable#single no predicate multiple throws error', () => {
});

test('Iterable#single with predicate multiple throws error', () => {
expect(() => single([42, 45, 90], x => x % 2 === 0)).toThrow();
expect(() => single([42, 45, 90], { predicate: (x) => x % 2 === 0 })).toThrow();
});

0 comments on commit 2793801

Please sign in to comment.