8000 fix(cdk-render-strategies): don't send complete event to strategy-behavior by hoebbelsB · Pull Request #954 · rx-angular/rx-angular · GitHub
[go: up one dir, main page]

Skip to content

fix(cdk-render-strategies): don't send complete event to strategy-behavior #954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 23, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test(cdk): implement test for local strategy to prove that it isn't w…
…orking
  • Loading branch information
hoebbelsB committed Sep 20, 2021
commit 23b9f77aaf190bd26e0a13b838860322ed934ea0
45 changes: 45 additions & 0 deletions libs/cdk/spec/render-strategies/local.strategy.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ɵglobal } from '@angular/core';
import { TestScheduler } from 'rxjs/testing';
import * as rxjs from 'rxjs';
// tslint:d 9125 isable-next-line:nx-enforce-module-boundaries
import { jestMatcher } from '@test-helpers';
// tslint:disable-next-line:nx-enforce-module-boundaries
import { accumulateObservables, animationFrameScheduler, RX_NATIVE_STRATEGIES } from '@rx-angular/cdk';
// tslint:disable-next-line:nx-enforce-module-boundaries
import { coalesceWith } from '@rx-angular/cdk/coalescing';
import { BehaviorSubject, from, Observable, observeOn, of } from 'rxjs';


let testScheduler: TestScheduler;
let handles = [];
let animationRuns = 0;
function animate() {
handles.forEach(handle => handle());
}
beforeEach(() => {
testScheduler = new TestScheduler(jestMatcher);
animationRuns = 0;
handles = [];
ɵglobal.requestAnimationFrame = (cb?) => {
handles[animationRuns] = cb;
animationRuns++;
return animationRuns;
}
ɵglobal.cancelAnimationFrame = (id: number) => {
handles = handles.splice(id, 1);
}
});

// tslint:disable: no-duplicate-string
describe('local strategy', () => {
it('should run on animationFrame', () => {
const values$ = from([1,2,3]);
const work = jest.fn();
values$.pipe(
RX_NATIVE_STRATEGIES.local.behavior(work)
).subscribe();
expect(work).not.toHaveBeenCalled();
animate();
expect(work).toHaveBeenCalled();
});
});
0