Skip to content

Commit

Permalink
test(cata): add 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n committed Apr 27, 2017
1 parent ac2c51f commit 9a9fda2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/cata.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ describe('cata', function() {
eq(RA.cata(null, identity, eitherR), 1);
});

it('test catamorphism on either method', function() {
const eitherRWithEither = Either.Right(1);
const eitherLWithEither = Either.Left(2);

eitherRWithEither.either = eitherRWithEither.cata;
eitherLWithEither.either = eitherLWithEither.cata;

eq(RA.cata(identity, identity, eitherRWithEither), 1);
eq(RA.cata(identity, identity, eitherLWithEither), 2);
});

it('tests on monad without catamorphic behavior', function() {
chai.assert.throws(RA.cata.bind(null, identity, identity, {}), TypeError);
chai.assert.throws(RA.cata.bind(null, identity, identity, null), TypeError);
Expand Down

0 comments on commit 9a9fda2

Please sign in to comment.