Skip to content

Commit bd3c5ef

Browse files
fix(operators): optimized tests
1 parent ddba84e commit bd3c5ef

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,16 @@ describe('auto pagination - mocked', function () {
2828
test('classic testing', async () => {
2929
const { autoPagination } = await import('./autoPagination');
3030

31-
const triggerValues = {
32-
a: { t: 2, v: { value: 'a', next: 1 } },
33-
b: { t: 5, v: { value: 'b', next: 2 } },
34-
c: { t: 3, v: { value: 'c', next: 3 } },
35-
d: { t: 1, v: { value: 'd', next: 4 } },
36-
e: { t: 4, v: { value: 'e', next: null } }
37-
};
31+
const triggerVal = [
32+
{ t: 2, v: { value: 'a', next: 1 } },
33+
{ t: 5, v: { value: 'b', next: 2 } },
34+
{ t: 3, v: { value: 'c', next: 3 } },
35+
{ t: 1, v: { value: 'd', next: 4 } },
36+
{ t: 4, v: { value: 'e', next: null } }
37+
];
3838

39-
const expectedVal = Array.from(Object.entries(triggerValues)).map(([k, { v }]) => v);
39+
const expectedVal = triggerVal.map(({ v }) => v);
4040

41-
const triggerVal = Object.values(triggerValues);
4241
await new Promise((done, error) => {
4342
of(triggerVal[0])
4443
.pipe(
@@ -56,7 +55,7 @@ describe('auto pagination - mocked', function () {
5655
});
5756
});
5857

59-
test.skip('marble testing', async () => {
58+
test('marble testing', async () => {
6059
const { autoPagination } = await import('./autoPagination');
6160

6261
const triggerVal = {

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ describe('concurrent request - mocked', function () {
1010
expect(actual).to.eql(expected);
1111
});
1212

13-
const getTriggerValues = () => ({
14-
a: { t: 2, v: 'a' },
15-
b: { t: 5, v: 'b' },
16-
c: { t: 1, v: 'c' },
17-
d: { t: 3, v: 'd' },
18-
e: { t: 4, v: 'e' }
19-
});
20-
2113
beforeEach(function () {
2214
vi.doMock('./request', importOriginal => ({
2315
request: () => source => source.pipe(concatMap(({ v, t }) => of(v).pipe(delay(t))))
@@ -31,7 +23,13 @@ describe('concurrent request - mocked', function () {
3123
test('classic testing', async () => {
3224
const { concurrentRequest } = await import('./concurrentRequest');
3325

34-
const triggerVal = Object.values(getTriggerValues());
26+
const triggerVal = [
27+
{ t: 20, v: 'a' },
28+
{ t: 50, v: 'b' },
29+
{ t: 10, v: 'c' },
30+
{ t: 30, v: 'd' },
31+
{ t: 40, v: 'e' }
32+
];
3533
const sortedVal = [...triggerVal].sort((a, b) => a.t - b.t).map(({ v }) => v);
3634

3735
await new Promise((done, error) => {
@@ -48,7 +46,13 @@ describe('concurrent request - mocked', function () {
4846
test('marble testing', async () => {
4947
const { concurrentRequest } = await import('./concurrentRequest');
5048

51-
const triggerVal = getTriggerValues();
49+
const triggerVal = {
50+
a: { t: 2, v: 'a' },
51+
b: { t: 5, v: 'b' },
52+
c: { t: 1, v: 'c' },
53+
d: { t: 3, v: 'd' },
54+
e: { t: 4, v: 'e' }
55+
};
5256
const expectedVal = Object.fromEntries(Object.entries(triggerVal).map(([k, { v }]) => [k, v]));
5357

5458
testScheduler.run(({ cold, expectObservable }) => {

0 commit comments

Comments
 (0)