mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
add tests for Fantom.scheduleTask (#50033)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50033 changelog: [internal] All public APIs should be covered with tests, this diff adds tests for Fantom.scheduleTask. Reviewed By: rubennorte Differential Revision: D71195921 fbshipit-source-id: dc7f0f889b9633b1e641dc8887fd506bc4753fe5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
01eafef8b4
commit
6e6e2ea0ca
@@ -829,3 +829,35 @@ describe('Fantom', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('scheduleTask', () => {
|
||||
it('does not run task immediately', () => {
|
||||
let didRun = false;
|
||||
|
||||
Fantom.scheduleTask(() => {
|
||||
didRun = true;
|
||||
});
|
||||
|
||||
expect(didRun).toBe(false);
|
||||
|
||||
Fantom.runWorkLoop();
|
||||
|
||||
expect(didRun).toBe(true);
|
||||
});
|
||||
|
||||
it('can be scheduled from within another task', () => {
|
||||
let didInnerTaskRun = false;
|
||||
|
||||
Fantom.scheduleTask(() => {
|
||||
Fantom.scheduleTask(() => {
|
||||
didInnerTaskRun = true;
|
||||
});
|
||||
});
|
||||
|
||||
expect(didInnerTaskRun).toBe(false);
|
||||
|
||||
Fantom.runWorkLoop();
|
||||
|
||||
expect(didInnerTaskRun).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user