11import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest' ;
22import { Workerify } from '../index.js' ;
3- import {
4- createMockRequest ,
5- setupBroadcastChannelMock ,
6- waitForAsync ,
7- } from './test-utils.js' ;
3+ import { setupBroadcastChannelMock } from './test-utils.js' ;
84
95// Setup mocks
106setupBroadcastChannelMock ( ) ;
@@ -134,8 +130,8 @@ describe('Workerify', () => {
134130
135131 // Mock routes acknowledgment
136132 setTimeout ( ( ) => {
137- const channel = workerify [ ' channel' ] as any ;
138- if ( channel && channel . listeners ) {
133+ const channel = workerify . channel as any ;
134+ if ( channel ? .listeners ) {
139135 channel . listeners . forEach ( ( listener : any ) => {
140136 listener ( {
141137 data : {
@@ -171,8 +167,8 @@ describe('Workerify', () => {
171167 } ) ;
172168
173169 setTimeout ( ( ) => {
174- const channel = workerify [ ' channel' ] as any ;
175- if ( channel && channel . listeners ) {
170+ const channel = workerify . channel as any ;
171+ if ( channel ? .listeners ) {
176172 channel . listeners . forEach ( ( listener : any ) => {
177173 listener ( {
178174 data : {
@@ -198,8 +194,8 @@ describe('Workerify', () => {
198194 } ) ;
199195
200196 setTimeout ( ( ) => {
201- const channel = workerify [ ' channel' ] as any ;
202- if ( channel && channel . listeners ) {
197+ const channel = workerify . channel as any ;
198+ if ( channel ? .listeners ) {
203199 channel . listeners . forEach ( ( listener : any ) => {
204200 listener ( {
205201 data : {
@@ -226,8 +222,8 @@ describe('Workerify', () => {
226222 } ) ;
227223
228224 setTimeout ( ( ) => {
229- const channel = workerify [ ' channel' ] as any ;
230- if ( channel && channel . listeners ) {
225+ const channel = workerify . channel as any ;
226+ if ( channel ? .listeners ) {
231227 channel . listeners . forEach ( ( listener : any ) => {
232228 listener ( {
233229 data : {
@@ -263,7 +259,7 @@ describe('Workerify', () => {
263259
264260 describe ( 'Integration with BroadcastChannel' , ( ) => {
265261 it ( 'should NOT send route updates when routes are registered (deferred to listen)' , async ( ) => {
266- const channelSpy = vi . spyOn ( workerify [ ' channel' ] , 'postMessage' ) ;
262+ const channelSpy = vi . spyOn ( workerify . channel , 'postMessage' ) ;
267263
268264 workerify . get ( '/test' , ( ) => 'test' ) ;
269265
@@ -272,7 +268,7 @@ describe('Workerify', () => {
272268 } ) ;
273269
274270 it ( 'should update service worker routes on listen' , async ( ) => {
275- const channelSpy = vi . spyOn ( workerify [ ' channel' ] , 'postMessage' ) ;
271+ const channelSpy = vi . spyOn ( workerify . channel , 'postMessage' ) ;
276272
277273 workerify . get ( '/test1' , ( ) => 'test1' ) ;
278274 workerify . post ( '/test2' , ( ) => 'test2' ) ;
@@ -286,8 +282,8 @@ describe('Workerify', () => {
286282 } ) ;
287283
288284 setTimeout ( ( ) => {
289- const channel = workerify [ ' channel' ] as any ;
290- if ( channel && channel . listeners ) {
285+ const channel = workerify . channel as any ;
286+ if ( channel ? .listeners ) {
291287 channel . listeners . forEach ( ( listener : any ) => {
292288 listener ( {
293289 data : {
0 commit comments