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

fix tests

parent 1114cffe
No related branches found
No related tags found
No related merge requests found
......@@ -25,8 +25,7 @@ import { selectorAuxMeshes } from "../store"
import { TouchSideClass } from "../touchSideClass.directive"
import { NehubaGlueCmp } from "./nehubaViewerGlue.component"
import { HarnessLoader } from "@angular/cdk/testing"
import { NehubaModule } from "../module"
import { NEHUBA_VIEWER_FEATURE_KEY } from "../constants"
import { AtlasWorkerService } from "src/atlasViewer/atlasViewer.workerService.service"
@Component({
......@@ -116,6 +115,18 @@ describe('> nehubaViewerGlue.component.ts', () => {
useValue: {
loadMeshes$: new Subject()
}
}, {
provide: AtlasWorkerService,
useValue: {
sendMessage: async () => {
return {
result: {
meta: {},
buffer: null
}
}
}
}
}
]
}).compileComponents()
......@@ -230,6 +241,7 @@ describe('> nehubaViewerGlue.component.ts', () => {
describe('> handleFileDrop', () => {
let addNgLayerSpy: jasmine.Spy
let removeNgLayersSpy: jasmine.Spy
let workerSendMessageSpy: jasmine.Spy
let dummyFile1: File
let dummyFile2: File
let input: File[]
......@@ -258,10 +270,19 @@ describe('> nehubaViewerGlue.component.ts', () => {
removeNgLayersSpy = spyOn(fixture.componentInstance['layerCtrlService'], 'removeNgLayers').and.callFake(() => {
})
workerSendMessageSpy = spyOn(fixture.componentInstance['worker'], 'sendMessage').and.callFake(async () => {
return {
result: {
meta: {}, buffer: null
}
}
})
})
afterEach(() => {
addNgLayerSpy.calls.reset()
removeNgLayersSpy.calls.reset()
workerSendMessageSpy.calls.reset()
})
describe('> malformed input', () => {
......@@ -305,11 +326,11 @@ describe('> nehubaViewerGlue.component.ts', () => {
})
describe('> correct input', () => {
beforeEach(() => {
beforeEach(async () => {
input = [dummyFile1]
const cmp = fixture.componentInstance
cmp.handleFileDrop(input)
await cmp.handleFileDrop(input)
})
afterEach(() => {
......@@ -321,9 +342,9 @@ describe('> nehubaViewerGlue.component.ts', () => {
expect(removeNgLayersSpy).not.toHaveBeenCalled()
expect(addNgLayerSpy).toHaveBeenCalledTimes(1)
})
it('> on repeated input, both remove nglayer and remove ng layer called', () => {
it('> on repeated input, both remove nglayer and remove ng layer called', async () => {
const cmp = fixture.componentInstance
cmp.handleFileDrop(input)
await cmp.handleFileDrop(input)
expect(removeNgLayersSpy).toHaveBeenCalledTimes(1)
expect(addNgLayerSpy).toHaveBeenCalledTimes(2)
......
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