Remove done callback usage from it(...) (#5514)

* Remove done callback usage from it(...)

* Bump deps

* continue-on-error: true
This commit is contained in:
Jaco
2023-03-01 13:13:38 +02:00
committed by GitHub
parent 697c8b8e7a
commit 0faddf1df6
10 changed files with 323 additions and 289 deletions
+28 -26
View File
@@ -9,41 +9,43 @@ import { of, timer } from 'rxjs';
import { drr } from '.';
describe('drr', (): void => {
it('should not fire twice the same value', (done): void => {
it('should not fire twice the same value', async (): Promise<void> => {
let count = 0;
const sub = of(1, 1).pipe(drr({ delay: 500 })).subscribe((): void => {
++count;
});
setTimeout((): void => {
expect(count).toBe(1);
sub.unsubscribe();
setTimeout(() => {
done();
}, 2000);
}, 50);
});
it('should be a ReplaySubject(1)', (done): void => {
const obs = timer(0, 100).pipe(drr({ delay: 500 })); // Starts at 0, increments every 100ms
const sub = obs.subscribe(); // Fire the observable
// Subscribe another time after some time, i.e. after the observable has fired
setTimeout((): void => {
const sub = obs.subscribe((value): void => {
expect(value > 1).toBe(true);
await new Promise<boolean>((resolve) => {
setTimeout((): void => {
expect(count).toBe(1);
sub.unsubscribe();
setTimeout(() => {
done();
resolve(true);
}, 2000);
});
}, 50);
});
});
it('should be a ReplaySubject(1)', async (): Promise<void> => {
const obs = timer(0, 100).pipe(drr({ delay: 500 })); // Starts at 0, increments every 100ms
const sub = obs.subscribe(); // Fire the observable
await new Promise<boolean>((resolve) => {
// Subscribe another time after some time, i.e. after the observable has fired
setTimeout((): void => {
const sub = obs.subscribe((value): void => {
expect(value > 1).toBe(true);
setTimeout(() => {
resolve(true);
}, 2000);
});
sub.unsubscribe();
}, 500);
sub.unsubscribe();
}, 500);
sub.unsubscribe();
});
});
});