Skip to content

Commit

Permalink
Merge pull request #85 from basics/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
StephanGerbeth authored Nov 24, 2024
2 parents ca3dfe4 + 271e580 commit 385e268
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions packages/operators/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Project Changelog

# [@rxjs-collection/operators-v1.0.7-beta.1](https://github.com/basics/rxjs-collection/compare/@rxjs-collection/operators-v1.0.6...@rxjs-collection/operators-v1.0.7-beta.1) (2024-11-24)


### Bug Fixes

* **operators:** cleanup ([daec245](https://github.com/basics/rxjs-collection/commit/daec245ffb1f6c5ea9001a47cb84a26717c45502))

# [@rxjs-collection/operators-v1.0.6](https://github.com/basics/rxjs-collection/compare/@rxjs-collection/operators-v1.0.5...@rxjs-collection/operators-v1.0.6) (2024-11-24)


Expand Down
2 changes: 1 addition & 1 deletion packages/operators/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rxjs-collection/operators",
"version": "1.0.6",
"version": "1.0.7-beta.1",
"description": "rxjs operators",
"license": "MIT",
"contributors": [
Expand Down
19 changes: 10 additions & 9 deletions packages/operators/src/request/cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,27 @@ describe('cache', () => {
});

test('default', () => {
const initial = new Response('initial', { status: 200 });
const updated = new Response('updated', { status: 200 });
const orderedResponses = [initial, updated];
const expectedVal = {
a: new Response('initial', { status: 200 }),
b: new Response('updated', { status: 200 })
};

const triggerVal = [expectedVal.a, expectedVal.b];

testScheduler.run(({ cold, expectObservable }) => {
const stream = cold('a', {
a: () => orderedResponses.shift()
}).pipe(
const stream = cold('a', { a: () => triggerVal.shift() }).pipe(
map(fn => fn()),
cache(2)
);

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

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

const unsubC = '---------^--!';
expectObservable(stream, unsubC).toBe('---------a', { a: updated }, new Error());
expectObservable(stream, unsubC).toBe('---------b', expectedVal, new Error());
});
});
});
22 changes: 10 additions & 12 deletions packages/operators/src/request/retry.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { map } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
import { beforeEach, describe, expect, test } from 'vitest';

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

afterEach(() => {
//
});

test('2x error -> 1x success', () => {
const error = new Response('', { status: 500 });
const success = new Response('a', { status: 200 });
const orderedResponses = [error, error, success];
const expectedVal = {
a: new Response('', { status: 500 }),
b: new Response('', { status: 500 }),
c: new Response('a', { status: 200 })
};

const triggerVal = [expectedVal.a, expectedVal.b, expectedVal.c];

testScheduler.run(({ cold, expectObservable }) => {
// retry is repeating the sequence
// if you define a delay, you have to add the delay to the subscribe multiple times (num retries)
const stream = cold('a|', {
a: () => orderedResponses.shift()
}).pipe(
const stream = cold('a|', { a: () => triggerVal.shift() }).pipe(
map(fn => fn()),
networkRetry({ timeout: () => 5 }),
log('marble:result')
);

const unsubA = '^-----------';
expectObservable(stream, unsubA).toBe('----------a|', { a: success });
expectObservable(stream, unsubA).toBe('----------c|', expectedVal);
});
});
});

0 comments on commit 385e268

Please sign in to comment.