Skip to content

Commit

Permalink
adding test for delay (#239)
Browse files Browse the repository at this point in the history
* adding test for delay

* tests
  • Loading branch information
vitaly-t authored Aug 3, 2024
1 parent 4bd0512 commit 6bc63fa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/ops/delay/async.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {_async, _asyncValues, expect} from '../../header';
import {pipe, delay} from '../../../src';
import {pipe, delay, consume} from '../../../src';

export default () => {
it('must emit after count', async () => {
Expand All @@ -26,14 +26,19 @@ export default () => {
const duration = Date.now() - start;
expect(duration).to.be.lessThan(10);
});

describe('for negative timeout', () => {
it('must not add delay for direct number', async () => {
const output = pipe(_async([1]), delay(-100));
const start = Date.now();
describe('for negative timeouts', () => {
it('must reuse the source iterable', async () => {
const source = _async([1, 2, 3]);
let destIterable;
const output = pipe(
source,
delay(-100),
consume((c) => {
destIterable = c;
})
);
await _asyncValues(output);
const duration = Date.now() - start;
expect(duration).to.be.lessThan(10);
expect(destIterable).to.eq(source);
});
it('must not add delay for callback result', async () => {
const output = pipe(
Expand Down

0 comments on commit 6bc63fa

Please sign in to comment.