Skip to content

Commit

Permalink
build(deps-dev): bump eventsource
Browse files Browse the repository at this point in the history
  • Loading branch information
Katarina Anton authored and kaciakmaciak committed May 29, 2022
1 parent 8dbbccd commit 845066a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 83 deletions.
86 changes: 9 additions & 77 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-testing-library": "4.6.0",
"eventsource": "1.1.0",
"eventsource": "2.0.2",
"husky": "7.0.0",
"jest": "27.0.6",
"lint-staged": "11.0.0",
Expand Down
14 changes: 9 additions & 5 deletions src/helpers/__tests__/event-source.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ describe('EventSource helpers', () => {
requestListener.mockClear();
});

function createAbsoluteUrl(relativePath: string): string {
return new URL(relativePath, window.location.href).toString();
}

describe('eventSource$', () => {
it('should emit values from event source', async () => {
const sse$ = eventSource$('/sse');
const sse$ = eventSource$(createAbsoluteUrl('/sse'));
expect(await firstValueFrom(sse$.pipe(take(5), toArray())))
.toMatchInlineSnapshot(`
Array [
Expand All @@ -45,7 +49,7 @@ describe('EventSource helpers', () => {
});

it('should not open the EventSource until subscribed', async () => {
const sse$ = eventSource$('/sse');
const sse$ = eventSource$(createAbsoluteUrl('/sse'));
expect(requestListener).not.toHaveBeenCalled();

const promise = firstValueFrom(sse$.pipe(take(5), toArray()));
Expand All @@ -55,14 +59,14 @@ describe('EventSource helpers', () => {
});

it('should close the EventSource once unsubscribed', async () => {
const sse$ = eventSource$('/sse');
const sse$ = eventSource$(createAbsoluteUrl('/sse'));
await firstValueFrom(sse$.pipe(take(5), toArray()));

expect(closeSseSpy).toHaveBeenCalledTimes(1);
});

it('should emit values from event source until error', async () => {
const sse$ = eventSource$('/sse/error');
const sse$ = eventSource$(createAbsoluteUrl('/sse/error'));
expect(
await firstValueFrom(
sse$.pipe(
Expand All @@ -83,7 +87,7 @@ describe('EventSource helpers', () => {

it('should fail to subscribe', async () => {
expect.assertions(2);
const sse$ = eventSource$('/sse/network-error');
const sse$ = eventSource$(createAbsoluteUrl('/sse/network-error'));
try {
await firstValueFrom(sse$.pipe(take(5), toArray()));
} catch (error) {
Expand Down

0 comments on commit 845066a

Please sign in to comment.