Skip to content

Commit

Permalink
Add test case with synchronous function at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
pito-svk committed May 10, 2017
1 parent e2c381d commit 3545eee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-train",
"version": "0.2.5",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
17 changes: 17 additions & 0 deletions test/mixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,20 @@ test('Synchronous function is in the middle', async t => {

t.is(actual, expected, 'Resulted value is 4')
})

test('Synchronous function at the end', async t => {
const double = x => 2 * x
const triple = x => 3 * x
const subtractFour = x => x - 4

const doubleAfter50ms = x => new Promise(resolve => setTimeout(() => resolve(double(x)), 50))
const tripleAfter50ms = x => new Promise(resolve => setTimeout(() => resolve(triple(x)), 50))

const actual = await train(9,
doubleAfter50ms, // 18
tripleAfter50ms, // 54
subtractFour) // 50
const expected = 50

t.is(actual, expected, 'Resulted value is 50')
})

0 comments on commit 3545eee

Please sign in to comment.