Skip to content

Commit daec245

Browse files
fix(operators): cleanup
1 parent ca3dfe4 commit daec245

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/operators/src/request/cache.test.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,27 @@ describe('cache', () => {
1212
});
1313

1414
test('default', () => {
15-
const initial = new Response('initial', { status: 200 });
16-
const updated = new Response('updated', { status: 200 });
17-
const orderedResponses = [initial, updated];
15+
const expectedVal = {
16+
a: new Response('initial', { status: 200 }),
17+
b: new Response('updated', { status: 200 })
18+
};
19+
20+
const triggerVal = [expectedVal.a, expectedVal.b];
1821

1922
testScheduler.run(({ cold, expectObservable }) => {
20-
const stream = cold('a', {
21-
a: () => orderedResponses.shift()
22-
}).pipe(
23+
const stream = cold('a', { a: () => triggerVal.shift() }).pipe(
2324
map(fn => fn()),
2425
cache(2)
2526
);
2627

2728
const unsubA = '-^!';
28-
expectObservable(stream, unsubA).toBe('-a', { a: initial }, new Error());
29+
expectObservable(stream, unsubA).toBe('-a', expectedVal, new Error());
2930

3031
const unsubB = '----^!';
31-
expectObservable(stream, unsubB).toBe('----a', { a: initial }, new Error());
32+
expectObservable(stream, unsubB).toBe('----a', expectedVal, new Error());
3233

3334
const unsubC = '---------^--!';
34-
expectObservable(stream, unsubC).toBe('---------a', { a: updated }, new Error());
35+
expectObservable(stream, unsubC).toBe('---------b', expectedVal, new Error());
3536
});
3637
});
3738
});
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { map } from 'rxjs';
22
import { TestScheduler } from 'rxjs/testing';
3-
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
3+
import { beforeEach, describe, expect, test } from 'vitest';
44

55
import { log } from '../log';
66
import { networkRetry } from './retry';
@@ -12,28 +12,26 @@ describe('request retry', () => {
1212
testScheduler = new TestScheduler((actual, expected) => expect(actual).deep.equal(expected));
1313
});
1414

15-
afterEach(() => {
16-
//
17-
});
18-
1915
test('2x error -> 1x success', () => {
20-
const error = new Response('', { status: 500 });
21-
const success = new Response('a', { status: 200 });
22-
const orderedResponses = [error, error, success];
16+
const expectedVal = {
17+
a: new Response('', { status: 500 }),
18+
b: new Response('', { status: 500 }),
19+
c: new Response('a', { status: 200 })
20+
};
21+
22+
const triggerVal = [expectedVal.a, expectedVal.b, expectedVal.c];
2323

2424
testScheduler.run(({ cold, expectObservable }) => {
2525
// retry is repeating the sequence
2626
// if you define a delay, you have to add the delay to the subscribe multiple times (num retries)
27-
const stream = cold('a|', {
28-
a: () => orderedResponses.shift()
29-
}).pipe(
27+
const stream = cold('a|', { a: () => triggerVal.shift() }).pipe(
3028
map(fn => fn()),
3129
networkRetry({ timeout: () => 5 }),
3230
log('marble:result')
3331
);
3432

3533
const unsubA = '^-----------';
36-
expectObservable(stream, unsubA).toBe('----------a|', { a: success });
34+
expectObservable(stream, unsubA).toBe('----------c|', expectedVal);
3735
});
3836
});
3937
});

0 commit comments

Comments
 (0)