Skip to content

Commit

Permalink
test(intg): split continuous evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
lemredd committed Dec 28, 2022
1 parent ba1afb0 commit c13eebf
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/components/CalculatorContainer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,38 @@ describe("Component: CalculatorContainer", () => {
await equalBtn.trigger("click")
expect(expressionScrn.text()).toEqual("1 + 1 =")
expect(entryScrn.text()).toEqual("2")
})

it("can evaluate continuously with `=` button", async() => {
const wrapper = mount(Component)
const expressionScrn = wrapper.find(".expression-screen")
const entryScrn = wrapper.find(".entry-screen")

// Find the digit "1" button and click it
const digitalBtns = wrapper.findAll(".digital-button")
const [digital1Btn] = digitalBtns.filter(btn => btn.text() === "1")
await digital1Btn.trigger("click")
expect(entryScrn.text()).toEqual("1")
expect(expressionScrn.text()).toEqual("")

// Find the Addition button and click it
const operationalBtns = wrapper.findAll(".operational-button")
const [additionBtn] = operationalBtns.filter(btn => btn.text() === "+")
await additionBtn.trigger("click")
expect(expressionScrn.text()).toEqual("1 +")

// click digit "1" button again
await digital1Btn.trigger("click")
expect(entryScrn.text()).toEqual("1")

// Find the Equal button and click it
const evaluationBtns = wrapper.findAll(".evaluation-button")
const [equalBtn] = evaluationBtns.filter(btn => btn.text() === "=")
await equalBtn.trigger("click")
expect(expressionScrn.text()).toEqual("1 + 1 =")
expect(entryScrn.text()).toEqual("2")

// Evaluate continuously
// Evaluate continuously with Equal button
await equalBtn.trigger("click")
expect(expressionScrn.text()).toEqual("2 + 1 =")
expect(entryScrn.text()).toEqual("3")
Expand Down

0 comments on commit c13eebf

Please sign in to comment.