@@ -240,9 +240,8 @@ describe('Abstract worker test suite', () => {
240240 } )
241241
242242 it ( 'Verify that getMainWorker() throw error if main worker is not set' , ( ) => {
243- expect ( ( ) =>
244- new StubWorkerWithMainWorker ( ( ) => { } ) . getMainWorker ( )
245- ) . toThrow ( 'Main worker not set' )
243+ expect ( ( ) => new StubWorkerWithMainWorker ( ( ) => { } ) . getMainWorker ( ) )
244+ . toThrow ( 'Main worker not set' )
246245 } )
247246
248247 it ( 'Verify that hasTaskFunction() is working' , ( ) => {
@@ -484,7 +483,6 @@ describe('Abstract worker test suite', () => {
484483 describe ( 'Message handling' , ( ) => {
485484 it ( 'Verify that messageEventListener() handles statistics message' , ( ) => {
486485 const worker = new ThreadWorker ( ( ) => { } )
487- // Set worker id manually for testing (normally set by handleReadyMessageEvent)
488486 worker . id = '550e8400-e29b-41d4-a716-446655440000'
489487 worker . messageEventListener ( {
490488 data : {
@@ -497,7 +495,6 @@ describe('Abstract worker test suite', () => {
497495
498496 it ( 'Verify that messageEventListener() handles checkActive message' , ( ) => {
499497 const worker = new ThreadWorker ( ( ) => { } )
500- // Set worker id manually for testing
501498 worker . id = '550e8400-e29b-41d4-a716-446655440000'
502499 worker . messageEventListener ( {
503500 data : {
@@ -517,7 +514,6 @@ describe('Abstract worker test suite', () => {
517514
518515 it ( 'Verify that messageEventListener() handles kill message' , ( ) => {
519516 const worker = new ThreadWorker ( ( ) => { } )
520- // Set worker id manually for testing
521517 worker . id = '550e8400-e29b-41d4-a716-446655440000'
522518 const sendToMainWorkerStub = stub ( worker , 'sendToMainWorker' )
523519 worker . messageEventListener ( {
@@ -557,7 +553,6 @@ describe('Abstract worker test suite', () => {
557553
558554 it ( 'Verify that messageEventListener() throws on mismatched workerId' , ( ) => {
559555 const worker = new ThreadWorker ( ( ) => { } )
560- // Set worker id manually for testing
561556 worker . id = '550e8400-e29b-41d4-a716-446655440000'
562557 expect ( ( ) =>
563558 worker . messageEventListener ( { data : { workerId : 'wrong-id' } } )
@@ -657,7 +652,9 @@ describe('Abstract worker test suite', () => {
657652 assertSpyCalls ( sendToMainWorkerStub , 1 )
658653 const lastCall = sendToMainWorkerStub . calls [ 0 ]
659654 expect ( lastCall . args [ 0 ] . workerError ) . toBeDefined ( )
660- expect ( lastCall . args [ 0 ] . workerError . error . message ) . toBe ( 'Async task error' )
655+ expect ( lastCall . args [ 0 ] . workerError . error . message ) . toBe (
656+ 'Async task error' ,
657+ )
661658 sendToMainWorkerStub . restore ( )
662659 } )
663660
@@ -702,9 +699,8 @@ describe('Abstract worker test suite', () => {
702699 taskFunctionProperties : { name : 'newFn' } ,
703700 } )
704701 expect ( worker . taskFunctions . has ( 'newFn' ) ) . toBe ( true )
705- // Called twice: once for sendTaskFunctionsPropertiesToMainWorker, once for operation response
706- expect ( sendToMainWorkerStub . calls . length ) . toBeGreaterThanOrEqual ( 1 )
707- const lastCall = sendToMainWorkerStub . calls [ sendToMainWorkerStub . calls . length - 1 ]
702+ assertSpyCalls ( sendToMainWorkerStub , 2 )
703+ const lastCall = sendToMainWorkerStub . calls [ 1 ]
708704 expect ( lastCall . args [ 0 ] . taskFunctionOperationStatus ) . toBe ( true )
709705 sendToMainWorkerStub . restore ( )
710706 } )
@@ -720,9 +716,8 @@ describe('Abstract worker test suite', () => {
720716 taskFunctionProperties : { name : 'fn2' } ,
721717 } )
722718 expect ( worker . taskFunctions . has ( 'fn2' ) ) . toBe ( false )
723- // Called twice: once for sendTaskFunctionsPropertiesToMainWorker, once for operation response
724- expect ( sendToMainWorkerStub . calls . length ) . toBeGreaterThanOrEqual ( 1 )
725- const lastCall = sendToMainWorkerStub . calls [ sendToMainWorkerStub . calls . length - 1 ]
719+ assertSpyCalls ( sendToMainWorkerStub , 2 )
720+ const lastCall = sendToMainWorkerStub . calls [ 1 ]
726721 expect ( lastCall . args [ 0 ] . taskFunctionOperationStatus ) . toBe ( true )
727722 sendToMainWorkerStub . restore ( )
728723 } )
@@ -739,9 +734,8 @@ describe('Abstract worker test suite', () => {
739734 expect ( worker . taskFunctions . get ( DEFAULT_TASK_NAME ) ) . toStrictEqual (
740735 worker . taskFunctions . get ( 'fn2' ) ,
741736 )
742- // Called twice: once for sendTaskFunctionsPropertiesToMainWorker, once for operation response
743- expect ( sendToMainWorkerStub . calls . length ) . toBeGreaterThanOrEqual ( 1 )
744- const lastCall = sendToMainWorkerStub . calls [ sendToMainWorkerStub . calls . length - 1 ]
737+ assertSpyCalls ( sendToMainWorkerStub , 2 )
738+ const lastCall = sendToMainWorkerStub . calls [ 1 ]
745739 expect ( lastCall . args [ 0 ] . taskFunctionOperationStatus ) . toBe ( true )
746740 sendToMainWorkerStub . restore ( )
747741 } )
@@ -808,7 +802,6 @@ describe('Abstract worker test suite', () => {
808802 const sendToMainWorkerStub = stub ( worker , 'sendToMainWorker' )
809803 worker . startCheckActive ( )
810804 await sleep ( 20 )
811- // May be called multiple times due to interval, check at least once
812805 expect ( sendToMainWorkerStub . calls . length ) . toBeGreaterThanOrEqual ( 1 )
813806 expect ( sendToMainWorkerStub . calls [ 0 ] . args [ 0 ] ) . toStrictEqual ( {
814807 kill : KillBehaviors . SOFT ,
0 commit comments