Skip to content

Commit

Permalink
test(createViewerTest): skip custom UI options
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHax committed May 16, 2023
1 parent dce91a0 commit 4b25059
Showing 1 changed file with 71 additions and 71 deletions.
142 changes: 71 additions & 71 deletions test/createViewerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,77 +574,77 @@ test('Test setImage and setLabelImage after createViewer', async t => {
})
})

test('Test createViewer custom UI options', async t => {
const gc = testUtils.createGarbageCollector(t)

const container = document.querySelector('body')
const viewerContainer = gc.registerDOMElement(document.createElement('div'))
container.appendChild(viewerContainer)

const response = await axios.get(testImage3DPath, {
responseType: 'arraybuffer',
})
const { image: itkImage, webWorker } = await readImageArrayBuffer(
null,
response.data,
'data.nrrd'
)
webWorker.terminate()

const referenceUIUrl = new URL(
'/base/src/UI/reference-ui/dist/referenceUIMachineOptions.js',
document.location.origin
)
const referenceUIMachineOptionsHref = { href: referenceUIUrl.href }

await createViewer(container, {
image: itkImage,
rotate: false,
config: { uiMachineOptions: referenceUIMachineOptionsHref },
})
t.pass('Viewer with UI module URL')

await createViewer(container, {
image: itkImage,
rotate: false,
config: {
uiMachineOptions: { href: referenceUIUrl.href, export: 'default' },
},
})
t.pass('Viewer with UI module URL, explicit export')

// If missing image.service.scaleSelector in options, test there is no warning
// Avoids this later occurring Error: Unable to send event to child 'scaleSelector' from service 'images'
const uiMachineOptionsNoImageServices = {
...referenceUIMachineOptions,
images: { ...referenceUIMachineOptions.images },
}
delete uiMachineOptionsNoImageServices.images.services

let isWarningLogged = false
const consoleWarn = console.warn
console.warn = message => {
if (message.includes("Warning: No service found for invocation '")) {
isWarningLogged = true
}
}
await createViewer(container, {
image: itkImage,
rotate: false,
config: {
uiMachineOptions: uiMachineOptionsNoImageServices,
},
})
console.warn = consoleWarn

t.same(
isWarningLogged,
false,
'custom options with no images.services has no warning'
)

gc.releaseResources()
})
// test('Test createViewer custom UI options', async t => {
// const gc = testUtils.createGarbageCollector(t)

// const container = document.querySelector('body')
// const viewerContainer = gc.registerDOMElement(document.createElement('div'))
// container.appendChild(viewerContainer)

// const response = await axios.get(testImage3DPath, {
// responseType: 'arraybuffer',
// })
// const { image: itkImage, webWorker } = await readImageArrayBuffer(
// null,
// response.data,
// 'data.nrrd'
// )
// webWorker.terminate()

// const referenceUIUrl = new URL(
// '/base/src/UI/reference-ui/dist/referenceUIMachineOptions.js',
// document.location.origin
// )
// const referenceUIMachineOptionsHref = { href: referenceUIUrl.href }

// await createViewer(container, {
// image: itkImage,
// rotate: false,
// config: { uiMachineOptions: referenceUIMachineOptionsHref },
// })
// t.pass('Viewer with UI module URL')

// await createViewer(container, {
// image: itkImage,
// rotate: false,
// config: {
// uiMachineOptions: { href: referenceUIUrl.href, export: 'default' },
// },
// })
// t.pass('Viewer with UI module URL, explicit export')

// // If missing image.service.scaleSelector in options, test there is no warning
// // Avoids this later occurring Error: Unable to send event to child 'scaleSelector' from service 'images'
// const uiMachineOptionsNoImageServices = {
// ...referenceUIMachineOptions,
// images: { ...referenceUIMachineOptions.images },
// }
// delete uiMachineOptionsNoImageServices.images.services

// let isWarningLogged = false
// const consoleWarn = console.warn
// console.warn = message => {
// if (message.includes("Warning: No service found for invocation '")) {
// isWarningLogged = true
// }
// }
// await createViewer(container, {
// image: itkImage,
// rotate: false,
// config: {
// uiMachineOptions: uiMachineOptionsNoImageServices,
// },
// })
// console.warn = consoleWarn

// t.same(
// isWarningLogged,
// false,
// 'custom options with no images.services has no warning'
// )

// gc.releaseResources()
// })

const makeImages = async paths => {
return Promise.all(
Expand Down

0 comments on commit 4b25059

Please sign in to comment.