Skip to content

Commit

Permalink
test: add failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Nov 13, 2021
1 parent fbaab9f commit 54688d4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
23 changes: 22 additions & 1 deletion spec/schedulers/AnimationFrameScheduler-spec.ts
Expand Up @@ -212,6 +212,27 @@ describe('Scheduler.animationFrame', () => {
});
});

it.skip('should properly cancel an unnecessary flush', (done) => {
it('should properly cancel an unnecessary flush', (done) => {
const sandbox = sinon.createSandbox();
const cancelAnimationFrameStub = sandbox.stub(animationFrameProvider, 'cancelAnimationFrame').callThrough();

let a: Subscription;
let b: Subscription;
let c: Subscription;

a = animationFrameScheduler.schedule(() => {
expect(animationFrameScheduler.actions).to.have.length(1);
c = animationFrameScheduler.schedule(() => { /* stupid lint rule */ });
expect(animationFrameScheduler.actions).to.have.length(2);
// What we're testing here is that the unsubscription of action c effects
// the cancellation of the animation frame in a scenario in which the
// actions queue is not empty - it contains action b.
c.unsubscribe();
expect(animationFrameScheduler.actions).to.have.length(1);
expect(cancelAnimationFrameStub).to.have.callCount(1);
sandbox.restore();
done();
});
b = animationFrameScheduler.schedule(() => { /* stupid lint rule */ });
});
});
23 changes: 22 additions & 1 deletion spec/schedulers/AsapScheduler-spec.ts
Expand Up @@ -262,6 +262,27 @@ describe('Scheduler.asap', () => {
});
});

it.skip('should properly cancel an unnecessary flush', (done) => {
it('should properly cancel an unnecessary flush', (done) => {
const sandbox = sinon.createSandbox();
const clearImmediateStub = sandbox.stub(immediateProvider, 'clearImmediate').callThrough();

let a: Subscription;
let b: Subscription;
let c: Subscription;

a = asapScheduler.schedule(() => {
expect(asapScheduler.actions).to.have.length(1);
c = asapScheduler.schedule(() => { /* stupid lint rule */ });
expect(asapScheduler.actions).to.have.length(2);
// What we're testing here is that the unsubscription of action c effects
// the cancellation of the microtask in a scenario in which the actions
// queue is not empty - it contains action b.
c.unsubscribe();
expect(asapScheduler.actions).to.have.length(1);
expect(clearImmediateStub).to.have.callCount(1);
sandbox.restore();
done();
});
b = asapScheduler.schedule(() => { /* stupid lint rule */ });
});
});

0 comments on commit 54688d4

Please sign in to comment.