Align Data.Raw decoding with Substrate (32-bytes) (#3573)
* Align Data.Raw decoding with Substrate (32-bytes) * CHANGELOG * Encoding test updates * provider.disconnect * Adjust provider tests * Unique connection URLs * Dangling tests * detectOpenHandles * Additional * Remove rx test (catered for by Promise wrap) * Additional cleanups to tests
This commit is contained in:
@@ -6,28 +6,39 @@ import { of, timer } from '@polkadot/x-rxjs';
|
||||
import { drr } from '.';
|
||||
|
||||
describe('drr', (): void => {
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(15000);
|
||||
});
|
||||
|
||||
it('should not fire twice the same value', (done): void => {
|
||||
let count = 0;
|
||||
|
||||
of(1, 1).pipe(drr()).subscribe((): void => { ++count; });
|
||||
const sub = of(1, 1).pipe(drr({ delay: 500 })).subscribe((): void => { ++count; });
|
||||
|
||||
setTimeout((): void => {
|
||||
expect(count).toBe(1);
|
||||
done();
|
||||
sub.unsubscribe();
|
||||
|
||||
setTimeout(done, 2000);
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('should be a ReplaySubject(1)', (done): void => {
|
||||
const obs = timer(0, 100).pipe(drr()); // Starts at 0, increments every 100ms
|
||||
const obs = timer(0, 100).pipe(drr({ delay: 500 })); // Starts at 0, increments every 100ms
|
||||
|
||||
obs.subscribe(); // Fire the observable
|
||||
const sub = obs.subscribe(); // Fire the observable
|
||||
|
||||
// Subscribe another time after some time, i.e. after the observable has fired
|
||||
setTimeout((): void => {
|
||||
obs.subscribe((value): void => {
|
||||
const sub = obs.subscribe((value): void => {
|
||||
expect(value > 1).toBe(true);
|
||||
done();
|
||||
|
||||
setTimeout(done, 2000);
|
||||
});
|
||||
|
||||
sub.unsubscribe();
|
||||
}, 500);
|
||||
|
||||
sub.unsubscribe();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user