Skip to content

Commit

Permalink
test: remove falsy removed storeService type reference
Browse files Browse the repository at this point in the history
  • Loading branch information
shaman-apprentice committed Oct 31, 2022
1 parent 5344d84 commit 55e1a3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
import { Node } from "../../../codeCharta.model"
import { CodeMapMesh } from "./codeMapMesh"
import { CodeMapBuilding } from "./codeMapBuilding"
import { StoreService } from "../../../state/store.service"
import { STATE, TEST_NODE_ROOT } from "../../../util/dataMocks"

describe("codeMapMesh", () => {
let storeService: StoreService
const testNodes: Node[] = [TEST_NODE_ROOT] // no need for 2 files

beforeEach(() => {
mockStoreService()
})

const mockStoreService = () => {
storeService = jest.fn().mockReturnValue({
getState: jest.fn().mockReturnValue(STATE)
})()
}

describe("setNewDeltaColor", () => {
let codeMapBuilding: CodeMapBuilding
const {
Expand All @@ -31,7 +19,7 @@ describe("codeMapMesh", () => {
}

const rebuildMesh = () => {
const codedMapMesh = new CodeMapMesh([TEST_NODE_ROOT], storeService.getState(), true)
const codedMapMesh = new CodeMapMesh([TEST_NODE_ROOT], STATE, true)
codeMapBuilding = codedMapMesh.getBuildingByPath(TEST_NODE_ROOT.path)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
import { Node } from "../../../codeCharta.model"
import { StoreService } from "../../../state/store.service"
import { clone } from "../../../util/clone"
import { STATE, TEST_NODE_ROOT } from "../../../util/dataMocks"
import { BuildResult, GeometryGenerator } from "./geometryGenerator"

describe("geometryGenerator", () => {
let geomGen: GeometryGenerator
let storeService: StoreService
let testNodes: Node[]
const state = clone(STATE)
state.dynamicSettings.heightMetric = "a" // set to a, since it is the delta defined in TEST_NODE_ROOT

beforeEach(() => {
mockStoreService()
initData()
})

const mockStoreService = () => {
STATE.dynamicSettings.heightMetric = "a" // set to a, since it is the delta defined in TEST_NODE_ROOT

storeService = jest.fn().mockReturnValue({
getState: jest.fn().mockReturnValue(STATE)
})()
}

const setTestNodes = () => {
const updatedNode = { heightDelta: -50 } // delta has to be negative why is that ?
return [TEST_NODE_ROOT].map(node => {
Expand All @@ -43,15 +35,15 @@ describe("geometryGenerator", () => {

it("should add delta to height when not flattened", () => {
setFlattened(false)
buildResult = geomGen.build(testNodes, null, storeService.getState(), true)
buildResult = geomGen.build(testNodes, null, state, true)

expect(testNodes[0].flat).toBeFalsy()
expect(buildResult.desc.buildings[0].boundingBox.max.y).toBe(58)
})

it("should not add delta to height when flattened", () => {
setFlattened(true)
buildResult = geomGen.build(testNodes, null, storeService.getState(), true)
buildResult = geomGen.build(testNodes, null, state, true)

expect(testNodes[0].flat).toBeTruthy()
expect(buildResult.desc.buildings[0].boundingBox.max.y).toBe(8)
Expand Down

0 comments on commit 55e1a3d

Please sign in to comment.