May 2019
Intermediate to advanced
496 pages
10h 38m
English
We'll repeat a lot of the same techniques in this section. There are two new concepts: first, pulling out the search param for the watcher ID, and second, using eventChannel to subscribe to the WebSocket onmessage callback:
describe('watching', () => { beforeEach(() => { Object.defineProperty(window, 'location', { writable: true, value: { host: 'test:1234', pathname: '/index.html', search: '?watching=234' } }); }); it('opens a socket when the page loads', () => { store.dispatch({ type: 'TRY_START_WATCHING' }); expect(socketSpyFactory).toHaveBeenCalledWith( 'ws://test:1234/share' ...Read now
Unlock full access