Skip to content

Commit

Permalink
test: Increased the coverage. Dropped testing with old node.js versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnasyrov committed Jul 25, 2021
1 parent a805a52 commit c26cf19
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
22 changes: 1 addition & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
Expand All @@ -24,23 +24,3 @@ jobs:
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

test-compatibility:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
node: ['12', '14', '16']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Test
run: npm run test
22 changes: 19 additions & 3 deletions packages/rx-effects/src/effect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
of,
tap,
throwError,
timeout,
timer,
} from 'rxjs';
import { switchMap, take, toArray } from 'rxjs/operators';
Expand Down Expand Up @@ -164,14 +165,29 @@ describe('Effect', () => {
const effect = createEffect((value: number) => value * 2);

const onSourceFailed = jest.fn();
effect.handle(throwError(new Error('test error')), {
onSourceFailed,
});
effect.handle(
throwError(() => new Error('test error')),
{
onSourceFailed,
},
);

expect(onSourceFailed).toBeCalledTimes(1);
expect(onSourceFailed).toBeCalledWith(new Error('test error'));
});

it('should do nothing in case the event source throws an error and onSourceFailed callback is not provided', async () => {
const effect = createEffect((value: number) => value * 2);

const finalPromise = firstValueFrom(effect.final$.pipe(timeout(10)));

expect(() =>
effect.handle(throwError(() => new Error('test error'))),
).not.toThrowError();

await expect(finalPromise).rejects.toThrowError('Timeout has occurred');
});

it('should handle error from the source', async () => {
const effect = createEffect((value: number) => value * 2);

Expand Down

0 comments on commit c26cf19

Please sign in to comment.