diff --git a/jest.config.js b/jest.config.js index 9cf0b7a..a082479 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,6 +17,6 @@ module.exports = { roots: ['/test'], testRegex: '/test/.*\\.(test|spec)?\\.(ts|tsx)$', transform: { '^.+\\.(js|ts|tsx)?$': ['ts-jest', { isolatedModules: true }] }, - transformIgnorePatterns: ['node_modules/(?!uuid)'], + transformIgnorePatterns: ['node_modules/(?!nanoid)'], testEnvironment: 'jsdom' } diff --git a/package.json b/package.json index ccc2498..a28d58a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-jet", - "version": "3.0.3", + "version": "3.0.4", "description": "Jet Realtime Message Bus for the Web. Daemon and Peer implementation.", "url": "https://github.com/hbm/node-jet", "author": { diff --git a/test/peer/peer.test.ts b/test/peer/peer.test.ts index 73ab4cd..8d160ea 100644 --- a/test/peer/peer.test.ts +++ b/test/peer/peer.test.ts @@ -165,7 +165,12 @@ describe('Testing Peer', () => { return true }) peer.fetch(m).then(() => { - cbs['___f___1'](undefined, 'fooId3', { params: { path: 'foo' } }) + Object.keys(cbs).forEach((key) => { + if (!['call', 'fetch_all', 'get', 'set'].includes(key)) { + cbs[key](undefined, 'fooId3', { params: { path: 'foo' } }) + } + }) + expect(fetchSpy).toBeCalledTimes(1) done() }) @@ -444,12 +449,14 @@ describe('Testing Peer', () => { jest.spyOn(JsonRPC, 'default').mockImplementation(() => jsonrpc) const peer = new Peer() peer.fetch(new Fetcher()).catch((ex) => { - expect(sendSpy).toBeCalledWith('fetch', { - id: '___f___1', - path: {}, - value: {}, - sort: {} - }) + expect(sendSpy).toBeCalledWith( + 'fetch', + expect.objectContaining({ + path: {}, + value: {}, + sort: {} + }) + ) expect(ex).toBe('invalid path') done() }) @@ -469,21 +476,26 @@ describe('Testing Peer', () => { .connect() .then(() => peer.fetch(new Fetcher().path('startsWith', 'a'))) .then(() => { - expect(sendSpy).toBeCalledWith('fetch', { - id: '___f___1', - path: { startsWith: 'a' }, - value: {}, - sort: {} - }) + expect(sendSpy).toBeCalledWith( + 'fetch', + expect.objectContaining({ + path: { startsWith: 'a' }, + value: {}, + sort: {} + }) + ) }) .then(() => peer.fetch(new Fetcher().path('equals', 'b'))) .then(() => { - expect(sendSpy).toBeCalledWith('fetch', { - id: '___f___2', - path: { equals: 'b' }, - value: {}, - sort: {} - }) + expect(sendSpy).toBeCalledWith( + 'fetch', + expect.objectContaining({ + path: { equals: 'b' }, + value: {}, + sort: {} + }) + ) + done() }) }) @@ -549,7 +561,7 @@ describe('Testing Peer', () => { .then(() => peer.fetch(fetcher)) .then(() => peer.unfetch(fetcher)) .then(() => { - expect(sendSpy).toBeCalledWith('unfetch', { id: '___f___1' }) + expect(sendSpy).toBeCalledWith('unfetch', expect.anything()) done() }) })