Skip to content

Commit 042158f

Browse files
committed
fix: tests
1 parent bc5d125 commit 042158f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/event-bus-client/tests/index.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from 'vitest'
22
import { ClientEventBus } from '@tanstack/devtools-event-bus/client'
33
import { EventClient } from '../src'
44

5+
vi.spyOn(BroadcastChannel.prototype, 'postMessage').mockImplementation(() => { })
56
// start the client bus for testing
67
const bus = new ClientEventBus()
78
bus.start()
@@ -55,7 +56,7 @@ describe('EventClient', () => {
5556
const targetEmitSpy = vi.spyOn(target, 'dispatchEvent')
5657
const targetListenSpy = vi.spyOn(target, 'addEventListener')
5758
const targetRemoveSpy = vi.spyOn(target, 'removeEventListener')
58-
const cleanup = client.on('test:event', () => {})
59+
const cleanup = client.on('test:event', () => { })
5960
cleanup()
6061
client.emit('test:event', { foo: 'bar' })
6162
expect(targetEmitSpy).toHaveBeenCalledWith(expect.any(Event))
@@ -79,7 +80,7 @@ describe('EventClient', () => {
7980
const targetEmitSpy = vi.spyOn(target, 'dispatchEvent')
8081
const targetListenSpy = vi.spyOn(target, 'addEventListener')
8182
const targetRemoveSpy = vi.spyOn(target, 'removeEventListener')
82-
const cleanup = client.on('test:event', () => {})
83+
const cleanup = client.on('test:event', () => { })
8384
cleanup()
8485
client.emit('test:event', { foo: 'bar' })
8586
expect(targetEmitSpy).toHaveBeenCalledWith(expect.any(Event))
@@ -102,7 +103,7 @@ describe('EventClient', () => {
102103
})
103104

104105
const eventBusSpy = vi.spyOn(clientBusEmitTarget, 'addEventListener')
105-
client.on('event', () => {})
106+
client.on('event', () => { })
106107
expect(eventBusSpy).toHaveBeenCalledWith(
107108
'test:event',
108109
expect.any(Function),

packages/event-bus/tests/index.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { afterEach, describe, expect, it, vi } from 'vitest'
22
import { ClientEventBus } from '../src/client'
33

4+
vi.spyOn(BroadcastChannel.prototype, 'postMessage').mockImplementation(() => { })
45
describe('ClientEventBus', () => {
56
describe('debug', () => {
67
afterEach(() => {
78
vi.restoreAllMocks()
89
})
910
it('should log events to the console when debug set to true', () => {
10-
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
11+
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { })
1112
const clientBus = new ClientEventBus({ debug: true })
1213
clientBus.start()
1314

@@ -20,7 +21,7 @@ describe('ClientEventBus', () => {
2021
})
2122

2223
it('should not log events to the console when debug set to false', () => {
23-
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
24+
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => { })
2425
const clientBus = new ClientEventBus({ debug: false })
2526
clientBus.start()
2627

0 commit comments

Comments
 (0)