Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
ref #2731
ref #2630
  • Loading branch information
Torsten Knauf authored and Torsten Knauf committed Mar 22, 2022
1 parent 010bddd commit 3e6e7a7
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { AttributeTypeValue } from "../../../codeCharta.model"
import { setAreaMetric } from "../../../state/store/dynamicSettings/areaMetric/areaMetric.actions"
import { setEdgeMetric } from "../../../state/store/dynamicSettings/edgeMetric/edgeMetric.actions"
import { setAttributeTypes } from "../../../state/store/fileSettings/attributeTypes/attributeTypes.actions"
import { Store } from "../../../state/store/store"
import { createAttributeTypeSelector } from "./createAttributeTypeSelector.selector"

describe("createAttributeTypeSelector", () => {
beforeEach(() => {
Store["initialize"]()
})

it("should default to 'Σ'", () => {
const attributeTypeSelector = createAttributeTypeSelector("nodes", "areaMetric")
expect(attributeTypeSelector(Store.store.getState())).toBe("Σ")
})

it("should read nodes", () => {
Store.store.dispatch(setAttributeTypes({ nodes: { rloc: AttributeTypeValue.relative } }))
Store.store.dispatch(setAreaMetric("rloc"))
const attributeTypeSelector = createAttributeTypeSelector("nodes", "areaMetric")
expect(attributeTypeSelector(Store.store.getState())).toBe("x͂")
})

it("should read edges", () => {
Store.store.dispatch(setAttributeTypes({ edges: { avgCommit: AttributeTypeValue.relative } }))
Store.store.dispatch(setEdgeMetric("avgCommit"))
const attributeTypeSelector = createAttributeTypeSelector("edges", "edgeMetric")
expect(attributeTypeSelector(Store.store.getState())).toBe("x͂")
})
})

0 comments on commit 3e6e7a7

Please sign in to comment.