Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from aslakhellesoy/install-as-native-promise
FinishedPromise.install() replaces native Promise
- Loading branch information
Showing
5 changed files
with
66 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
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,2 @@ | ||
#!/usr/bin/env bash | ||
node_modules/.bin/async-node node_modules/.bin/_mocha "$@" |
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,40 @@ | ||
const assert = require('assert') | ||
const FinishedPromise = require('..') | ||
|
||
describe('Promise', () => { | ||
before(() => { | ||
FinishedPromise.install() | ||
}) | ||
|
||
after(() => { | ||
FinishedPromise.uninstall() | ||
}) | ||
|
||
it('is replaced with FinishedPromise', () => { | ||
let result | ||
|
||
function f1(v) { | ||
return Promise.resolve(v) | ||
} | ||
function f2(v) { | ||
result = v | ||
} | ||
|
||
Promise.resolve(123).then(f1).then(f2) | ||
assert.equal(result, 123) | ||
}) | ||
|
||
it('is replaced with FinishedPromise in async functions', () => { | ||
let result | ||
|
||
async function f1(v) { | ||
return v | ||
} | ||
async function f2(v) { | ||
result = v | ||
} | ||
|
||
Promise.resolve(123).then(f1).then(f2) | ||
assert.equal(result, 123) | ||
}) | ||
}) |