33 generateFrameImageId ,
44} from '../../src/utilities/splitImageIdsBy4DTags' ;
55import { metaData } from '@cornerstonejs/metadata' ;
6+ import { logging } from '@cornerstonejs/utils' ;
67import {
78 describe ,
89 it ,
@@ -115,26 +116,36 @@ describe('splitImageIdsBy4DTags - Multiframe 4D Functions', () => {
115116 } ) ;
116117
117118 it ( 'should return null when TimeSlotVector length does not match NumberOfFrames' , ( ) => {
118- const consoleWarnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ) ;
119+ const loggerWarnSpy = jest
120+ . spyOn (
121+ logging . metadataLog . getLogger ( 'utilities.splitImageIdsBy4DTags' ) ,
122+ 'warn'
123+ )
124+ . mockImplementation ( ) ;
119125 mockMetaDataGet . mockReturnValue ( {
120126 NumberOfFrames : 4 ,
121127 TimeSlotVector : [ 1 , 1 , 2 ] ,
122128 } ) ;
123129 const result = handleMultiframe4D ( [ baseImageId ] ) ;
124130
125131 expect ( result ) . toBeNull ( ) ;
126- expect ( consoleWarnSpy ) . toHaveBeenCalledWith (
132+ expect ( loggerWarnSpy ) . toHaveBeenCalledWith (
127133 'TimeSlotVector length does not match NumberOfFrames:' ,
128134 3 ,
129135 'vs' ,
130136 4
131137 ) ;
132138
133- consoleWarnSpy . mockRestore ( ) ;
139+ loggerWarnSpy . mockRestore ( ) ;
134140 } ) ;
135141
136142 it ( 'should return null when SliceVector length does not match NumberOfFrames' , ( ) => {
137- const consoleWarnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ) ;
143+ const loggerWarnSpy = jest
144+ . spyOn (
145+ logging . metadataLog . getLogger ( 'utilities.splitImageIdsBy4DTags' ) ,
146+ 'warn'
147+ )
148+ . mockImplementation ( ) ;
138149 mockMetaDataGet . mockReturnValue ( {
139150 NumberOfFrames : 4 ,
140151 TimeSlotVector : [ 1 , 1 , 2 , 2 ] ,
@@ -143,18 +154,23 @@ describe('splitImageIdsBy4DTags - Multiframe 4D Functions', () => {
143154 const result = handleMultiframe4D ( [ baseImageId ] ) ;
144155
145156 expect ( result ) . toBeNull ( ) ;
146- expect ( consoleWarnSpy ) . toHaveBeenCalledWith (
157+ expect ( loggerWarnSpy ) . toHaveBeenCalledWith (
147158 'SliceVector exists but has invalid length or undefined entries. Expected length:' ,
148159 4 ,
149160 'Actual length:' ,
150161 3
151162 ) ;
152163
153- consoleWarnSpy . mockRestore ( ) ;
164+ loggerWarnSpy . mockRestore ( ) ;
154165 } ) ;
155166
156167 it ( 'should return null when SliceVector has undefined entries' , ( ) => {
157- const consoleWarnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ) ;
168+ const loggerWarnSpy = jest
169+ . spyOn (
170+ logging . metadataLog . getLogger ( 'utilities.splitImageIdsBy4DTags' ) ,
171+ 'warn'
172+ )
173+ . mockImplementation ( ) ;
158174 mockMetaDataGet . mockReturnValue ( {
159175 NumberOfFrames : 4 ,
160176 TimeSlotVector : [ 1 , 1 , 2 , 2 ] ,
@@ -163,18 +179,23 @@ describe('splitImageIdsBy4DTags - Multiframe 4D Functions', () => {
163179 const result = handleMultiframe4D ( [ baseImageId ] ) ;
164180
165181 expect ( result ) . toBeNull ( ) ;
166- expect ( consoleWarnSpy ) . toHaveBeenCalledWith (
182+ expect ( loggerWarnSpy ) . toHaveBeenCalledWith (
167183 'SliceVector exists but has invalid length or undefined entries. Expected length:' ,
168184 4 ,
169185 'Actual length:' ,
170186 4
171187 ) ;
172188
173- consoleWarnSpy . mockRestore ( ) ;
189+ loggerWarnSpy . mockRestore ( ) ;
174190 } ) ;
175191
176192 it ( 'should return null when SliceVector is not an array' , ( ) => {
177- const consoleWarnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ) ;
193+ const loggerWarnSpy = jest
194+ . spyOn (
195+ logging . metadataLog . getLogger ( 'utilities.splitImageIdsBy4DTags' ) ,
196+ 'warn'
197+ )
198+ . mockImplementation ( ) ;
178199 mockMetaDataGet . mockReturnValue ( {
179200 NumberOfFrames : 4 ,
180201 TimeSlotVector : [ 1 , 1 , 2 , 2 ] ,
@@ -183,12 +204,12 @@ describe('splitImageIdsBy4DTags - Multiframe 4D Functions', () => {
183204 const result = handleMultiframe4D ( [ baseImageId ] ) ;
184205
185206 expect ( result ) . toBeNull ( ) ;
186- expect ( consoleWarnSpy ) . toHaveBeenCalledWith (
207+ expect ( loggerWarnSpy ) . toHaveBeenCalledWith (
187208 'SliceVector exists but is not an array. Expected length:' ,
188209 4
189210 ) ;
190211
191- consoleWarnSpy . mockRestore ( ) ;
212+ loggerWarnSpy . mockRestore ( ) ;
192213 } ) ;
193214 } ) ;
194215} ) ;
0 commit comments