forked from graphql/graphql-js
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'resolveOnNextTick' to use in tests (graphql#2778)
instead of Node.js specific methods
- Loading branch information
1 parent
fbe8402
commit 4f26a6b
Showing
5 changed files
with
38 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
|
||
import resolveOnNextTick from '../resolveOnNextTick'; | ||
|
||
describe('resolveOnNextTick', () => { | ||
it('resolves promise on the next tick', async () => { | ||
const output = []; | ||
|
||
const promise1 = resolveOnNextTick().then(() => { | ||
output.push('second'); | ||
}); | ||
const promise2 = resolveOnNextTick().then(() => { | ||
output.push('third'); | ||
}); | ||
output.push('first'); | ||
|
||
await Promise.all([promise1, promise2]); | ||
expect(output).to.deep.equal(['first', 'second', 'third']); | ||
}); | ||
}); |
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,3 @@ | ||
export default function resolveOnNextTick(): Promise<void> { | ||
return Promise.resolve(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
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