-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
d66d493
commit 3f83307
Showing
5 changed files
with
55 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { expect } = require('chai') | ||
|
||
const { cond, constant, prop } = require('..') | ||
|
||
describe('cond', () => { | ||
const conditional = | ||
cond([ | ||
[ prop('foo'), constant('yes') ], | ||
[ prop('bar'), constant('no') ] | ||
]) | ||
|
||
it('accepts a list of if/else pred and transformer pairs', () => { | ||
expect(conditional({ foo: true })).to.equal('yes') | ||
expect(conditional({ bar: true })).to.equal('no') | ||
}) | ||
|
||
it('returns undefined if no preds match', () => | ||
expect(conditional({ none: true })).to.be.undefined | ||
) | ||
}) |
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,22 @@ | ||
const { expect } = require('chai') | ||
|
||
const { pathEq } = require('..') | ||
|
||
describe('pathEq', () => { | ||
const obj = { foo: { bar: 'yes' } } | ||
|
||
it('tests if a nested path is identically equal to a value', () => { | ||
expect(pathEq(['foo', 'bar'], 'yes', obj)).to.be.true | ||
expect(pathEq(['foo', 'bar'], 'no', obj)).to.be.false | ||
}) | ||
|
||
it('does not fail if the path is missing', () => | ||
expect(pathEq(['bar', 'foo'], 'yes', obj)).to.be.false | ||
) | ||
|
||
it('is curried', () => { | ||
expect(pathEq(['foo', 'bar'])('yes', obj)).to.be.true | ||
expect(pathEq(['foo', 'bar'], 'yes')(obj)).to.be.true | ||
expect(pathEq(['foo', 'bar'])('yes')(obj)).to.be.true | ||
}) | ||
}) |
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,10 @@ | ||
const { expect } = require('chai') | ||
|
||
const { unit } = require('..') | ||
|
||
describe('unit', () => { | ||
it('always returns undefined', () => { | ||
expect(unit('a')).to.be.undefined | ||
expect(unit()).to.be.undefined | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.