-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unit(component): ensure various clearing emissions
- Loading branch information
Showing
1 changed file
with
34 additions
and
8 deletions.
There are no files selected for viewing
42 changes: 34 additions & 8 deletions
42
src/components/CalculatorContainer/CorrectionButton.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | ||
}) | ||
}) |