Skip to content

Commit

Permalink
Add test cases #1234
Browse files Browse the repository at this point in the history
  • Loading branch information
Nereboss authored and fritschldwg committed Jan 12, 2024
1 parent 454a11a commit 589cc0e
Showing 1 changed file with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -846,12 +846,50 @@ describe("codeMapMouseEventService", () => {
})

describe("labelForSelectedBuilding", () => {
it("should create a label when clicking on a building", () => {})
it("should create a label when selecting a building", () => {
threeSceneService.getLabelForHoveredNode = jest.fn()
threeSceneService.animateLabel = jest.fn()
codeMapLabelService.addLeafLabel = jest.fn()

it("should remove the label when the building is unselected", () => {})
codeMapMouseEventService["drawLabelForSelected"](codeMapBuilding)

expect(threeSceneService.getLabelForHoveredNode).toHaveBeenCalled()
expect(codeMapLabelService.addLeafLabel).toHaveBeenCalledWith(codeMapBuilding.node, 0, true)
expect(codeMapMouseEventService["temporaryLabelForSelectedBuilding"]).toEqual(codeMapBuilding.node)
})

it("should remove the label when a previously selected building is unselected", () => {
threeSceneService.getLabelForHoveredNode = jest.fn()
threeSceneService.animateLabel = jest.fn()
codeMapLabelService.clearTemporaryLabel = jest.fn()
codeMapMouseEventService["drawLabelForSelected"](codeMapBuilding)

it("should remove the old and create the new label when selected building is changed", () => {})
codeMapMouseEventService["clearLabelForSelected"]()

it("should keep the label when clicking on the already selected building", () => {})
expect(codeMapLabelService.clearTemporaryLabel).toHaveBeenCalledWith(codeMapBuilding.node)
expect(codeMapMouseEventService["temporaryLabelForSelectedBuilding"]).toBeNull()
})

it("should remove the old and create the new label when selected building is changed", () => {
//TODO we need two buildings for this, check if we have two in the mocks
})

it("should keep the label when clicking on the already selected building", () => {
threeSceneService.getLabelForHoveredNode = jest.fn()
threeSceneService.animateLabel = jest.fn()
codeMapMouseEventService["clearTemporaryLabel"] = jest.fn()
codeMapMouseEventService["drawLabelForSelected"] = jest.fn()

codeMapMouseEventService["drawLabelForSelected"](codeMapBuilding)
const referenceLabel = codeMapMouseEventService["temporaryLabelForSelectedBuilding"]
codeMapMouseEventService["intersectedBuilding"] = codeMapBuilding

codeMapMouseEventService["onLeftClick"]()

expect(codeMapMouseEventService["drawLabelForSelected"]).toHaveBeenCalledWith(codeMapBuilding)
expect(codeMapMouseEventService["drawLabelForSelected"]).toHaveBeenCalledTimes(2)
expect(codeMapMouseEventService["clearTemporaryLabel"]).not.toHaveBeenCalled()
expect(codeMapMouseEventService["temporaryLabelForSelectedBuilding"]).toEqual(referenceLabel)
})
})
})

0 comments on commit 589cc0e

Please sign in to comment.