Skip to content

Commit

Permalink
Add a regression test for cancelCallback with message loop
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Aug 15, 2019
1 parent 868d02d commit c2a1a77
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/scheduler/src/__tests__/SchedulerBrowser-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
let Scheduler;
let runtime;
let performance;
let cancelCallback;
let scheduleCallback;
let NormalPriority;

Expand Down Expand Up @@ -52,6 +53,7 @@ describe('SchedulerBrowser', () => {
performance = window.performance;
require('scheduler/src/SchedulerFeatureFlags').enableMessageLoopImplementation = enableMessageLoopImplementation;
Scheduler = require('scheduler');
cancelCallback = Scheduler.unstable_cancelCallback;
scheduleCallback = Scheduler.unstable_scheduleCallback;
NormalPriority = Scheduler.unstable_NormalPriority;
});
Expand Down Expand Up @@ -418,5 +420,24 @@ describe('SchedulerBrowser', () => {
runtime.fireMessageEvent();
runtime.assertLog(['Message Event', 'B']);
});

it('schedule new task after a cancellation', () => {
let handle = scheduleCallback(NormalPriority, () => {
runtime.log('A');
});

runtime.assertLog(['Post Message']);
cancelCallback(handle);

runtime.fireMessageEvent();
runtime.assertLog(['Message Event']);

scheduleCallback(NormalPriority, () => {
runtime.log('B');
});
runtime.assertLog(['Post Message']);
runtime.fireMessageEvent();
runtime.assertLog(['Message Event', 'B']);
});
});
});

0 comments on commit c2a1a77

Please sign in to comment.