Skip to content
Snippets Groups Projects
Unverified Commit c2d439fd authored by Xiao Gui's avatar Xiao Gui
Browse files

fix: tests

parent f5de84e0
No related branches found
No related tags found
No related merge requests found
......@@ -158,13 +158,13 @@ describe("> effects.ts", () => {
},
previous: {
atlas: {
"@id": IDS.ATLAES.RAT
id: IDS.ATLAES.RAT
} as any,
parcellation: {
"@id": IDS.PARCELLATION.WAXHOLMV4
id: IDS.PARCELLATION.WAXHOLMV4
} as any,
template: {
"@id": IDS.TEMPLATES.WAXHOLM
id: IDS.TEMPLATES.WAXHOLM
} as any,
}
})
......@@ -186,24 +186,24 @@ describe("> effects.ts", () => {
const obs = hook({
current: {
atlas: {
"@id": IDS.ATLAES.HUMAN
id: IDS.ATLAES.HUMAN
} as any,
parcellation: {
"@id": IDS.PARCELLATION.JBA29
id: IDS.PARCELLATION.JBA29
} as any,
template: {
"@id": IDS.TEMPLATES.MNI152
id: IDS.TEMPLATES.MNI152
} as any,
},
previous: {
atlas: {
"@id": IDS.ATLAES.RAT
id: IDS.ATLAES.RAT
} as any,
parcellation: {
"@id": IDS.PARCELLATION.WAXHOLMV4
id: IDS.PARCELLATION.WAXHOLMV4
} as any,
template: {
"@id": IDS.TEMPLATES.WAXHOLM
id: IDS.TEMPLATES.WAXHOLM
} as any,
}
})
......
......@@ -5,6 +5,7 @@ import { LoggingModule, LoggingService } from "src/logging"
import { IMeshesToLoad, SET_MESHES_TO_LOAD } from "../constants"
import { Subject } from "rxjs"
import { IColorMap, SET_COLORMAP_OBS, SET_LAYER_VISIBILITY } from "../layerCtrl.service"
import { rgbToHex } from 'common/util'
describe('> nehubaViewer.component.ts', () => {
describe('> #scanFn', () => {
......@@ -305,15 +306,42 @@ describe('> nehubaViewer.component.ts', () => {
describe('> # setColorMap', () => {
let nehubaViewerSpy: any
let ngViewerStatechildrenGetSpy = jasmine.createSpy('get')
let toJsonSpy = jasmine.createSpy('toJsonSpy')
let restoreStateSpy = jasmine.createSpy('restoreStateSpy')
const ngId1 = 'foo-bar'
const ngId2 = 'hello-world'
beforeEach(() => {
nehubaViewerSpy = {
batchAddAndUpdateSegmentColors: jasmine.createSpy(),
dispose(){
},
ngviewer: {
state: {
children: {
get: ngViewerStatechildrenGetSpy
}
}
}
}
ngViewerStatechildrenGetSpy.and.returnValue({
toJSON: toJsonSpy,
restoreState: restoreStateSpy,
})
toJsonSpy.and.returnValue([{
name: ngId1
}, {
name: ngId2
}])
})
it('> calls nehubaViewer.batchAddAndUpdateSegmentColors', () => {
afterEach(() => {
ngViewerStatechildrenGetSpy.calls.reset()
toJsonSpy.calls.reset()
restoreStateSpy.calls.reset()
})
it('> calls nehubaViewer.restoreState', () => {
const fixture = TestBed.createComponent(NehubaViewerUnit)
fixture.componentInstance.nehubaViewer = nehubaViewerSpy
fixture.detectChanges()
......@@ -322,28 +350,28 @@ describe('> nehubaViewer.component.ts', () => {
const fooBarMap = new Map()
fooBarMap.set(1, {red: 100, green: 100, blue: 100})
fooBarMap.set(2, {red: 200, green: 200, blue: 200})
mainMap.set('foo-bar', fooBarMap)
mainMap.set(ngId1, fooBarMap)
const helloWorldMap = new Map()
helloWorldMap.set(1, {red: 10, green: 10, blue: 10})
helloWorldMap.set(2, {red: 20, green: 20, blue: 20})
mainMap.set('hello-world', helloWorldMap)
mainMap.set(ngId2, helloWorldMap)
fixture.componentInstance['setColorMap'](mainMap)
expect(
nehubaViewerSpy.batchAddAndUpdateSegmentColors
).toHaveBeenCalledTimes(2)
expect(nehubaViewerSpy.batchAddAndUpdateSegmentColors).toHaveBeenCalledWith(
fooBarMap,
{ name: 'foo-bar' }
)
expect(nehubaViewerSpy.batchAddAndUpdateSegmentColors).toHaveBeenCalledWith(
helloWorldMap,
{ name: 'hello-world' }
)
expect(restoreStateSpy).toHaveBeenCalledOnceWith([{
name: ngId1,
segmentColors: {
1: rgbToHex([100, 100, 100]),
2: rgbToHex([200, 200, 200]),
}
}, {
name: ngId2,
segmentColors: {
1: rgbToHex([10, 10, 10]),
2: rgbToHex([20, 20, 20]),
}
}])
})
})
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment