Skip to content

Commit

Permalink
test(component): ensure square root evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
lemredd committed Jan 6, 2023
1 parent 9fa28a8 commit 54a11cf
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/components/CalculatorContainer/EvaluationButton.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,29 @@ describe("Component: CalculatorContainer/EvaluationButton", () => {
const expectedEvaluationResult = entry * entry
expect(expectedEmission).toHaveProperty("0.1", expectedEvaluationResult)
})

it("can obtain square root of given entry", async() => {
const expressionAndPreviousResultInformation = {
"hasSavedPreviousResult": false,
"operation": null,
"previousEntry": null,
"previousResult": "0",
"rightEntry": null
}
const wrapper = shallowMount(Component, {
"props": {
"entry": "9",
expressionAndPreviousResultInformation,
"expressionToEvaluate": "",
"value": "√"
}
})
const evaluationBtn = wrapper.find(".evaluation-button")
await evaluationBtn.trigger("click")

const expectedEmission = wrapper.emitted("emitEvaluationResult")
const { entry } = wrapper.props()
const expectedEvaluationResult = Math.sqrt(entry)
expect(expectedEmission).toHaveProperty("0.1", expectedEvaluationResult)
})
})

0 comments on commit 54a11cf

Please sign in to comment.