Skip to content

Commit

Permalink
unit(component): ensure various clearing emissions
Browse files Browse the repository at this point in the history
  • Loading branch information
lemredd committed Dec 20, 2022
1 parent 2ebf50d commit bfc445c
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions src/components/CalculatorContainer/CorrectionButton.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
import { shallowMount } from "@vue/test-utils"

import { Corrections } from "@/types/buttons"

import Component from "./CorrectionButton.vue"

describe("Component: CalculatorContainer/CorrectionButton", () => {
it("can emit custom value", async() => {
it("can emit clearing of user entry screen", async() => {
const props = {
"value": "CE" as Corrections
}
const wrapper = shallowMount(Component, {
props
})
const correctionBtn = wrapper.find("button.correction-button")

await correctionBtn.trigger("click")
expect(wrapper.emitted()).toHaveProperty(("clearEntryScreen"))
})

it("can emit clearing of all screens", async() => {
const props = {
"value": "C" as Corrections
}
const wrapper = shallowMount(Component, {
props
})
const correctionBtn = wrapper.find("button.correction-button")

await correctionBtn.trigger("click")
expect(wrapper.emitted()).toHaveProperty(("clearAllScreens"))
})

it("can emit clearing of one digit", async() => {
const props = {
"value": "" as Corrections
}
const wrapper = shallowMount(Component, {
"props": {
"value": "CE"
}
props
})
const correctionBtn = wrapper.find("button.correction-button")
const correctionBtnValue = wrapper.props("value")
expect(correctionBtn.text()).toEqual(String(correctionBtnValue))

await correctionBtn.trigger("click")
const expectedEmission = wrapper.emitted("appendToScreen")
expect(expectedEmission).toHaveProperty("0.0", correctionBtnValue)
expect(wrapper.emitted()).toHaveProperty(("clearOneDigit"))
})
})

0 comments on commit bfc445c

Please sign in to comment.