generated from customcommander/project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 0
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
b3e872c
commit b6409df
Showing
2 changed files
with
57 additions
and
1 deletion.
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,28 @@ | ||
const test = require('tape'); | ||
const td = require('testdouble'); | ||
const {flip} = require('../dist'); | ||
|
||
test('flip inverts the order of the first two parameters.', t => { | ||
const fn = td.function(); | ||
const flipped = flip(fn); | ||
flipped('foo')('bar'); | ||
td.verify(fn('bar', 'foo')); | ||
flipped('baz', 'bat'); | ||
td.verify(fn('bat', 'baz')); | ||
t.end(); | ||
}); | ||
|
||
test('flip forwards the rest of the parameters.', t => { | ||
const fn = td.function(); | ||
const flipped = flip(fn); | ||
flipped('foo')('bar', 'baz'); | ||
td.verify(fn('bar', 'foo', 'baz')); | ||
flipped('foo', 'bar', 'baz', 'bat'); | ||
td.verify(fn('bar', 'foo', 'baz', 'bat')); | ||
t.end(); | ||
}); | ||
|
||
test('flip fails when not given a function.', t => { | ||
t.throws(() => flip([])); | ||
t.end(); | ||
}); |