forked from Meituan-Dianping/mpvue
-
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.
Add promise support to nextTick (#3967)
* add promise support to nextTick * remove test for non-existent nextTick console error * Update flow annotation for callback * Revert flow annotation for nextTick callback
- Loading branch information
1 parent
048014a
commit 8bf2653
Showing
4 changed files
with
54 additions
and
8 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
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,25 @@ | ||
import { nextTick } from 'core/util/env' | ||
|
||
describe('nextTick', () => { | ||
it('accepts a callback', done => { | ||
nextTick(done) | ||
}) | ||
|
||
it('returns undefined when passed a callback', () => { | ||
expect(typeof nextTick(() => {})).toBe('undefined') | ||
}) | ||
|
||
if (typeof Promise !== 'undefined') { | ||
it('returns a Promise when provided no callback', done => { | ||
nextTick().then(done) | ||
}) | ||
|
||
it('returns a Promise with a context argument when provided a falsy callback and an object', done => { | ||
const obj = {} | ||
nextTick(undefined, obj).then(ctx => { | ||
expect(ctx).toBe(obj) | ||
done() | ||
}) | ||
}) | ||
} | ||
}) |