diff --git a/src/ux-components/button-main/button-main.spec.js b/src/ux-components/button-main/button-main.spec.js index 32686a70a..c746bb24d 100644 --- a/src/ux-components/button-main/button-main.spec.js +++ b/src/ux-components/button-main/button-main.spec.js @@ -102,6 +102,82 @@ describe("buttonMain.vue", () => { const loader = wrapper.find("loader-stub"); expect(wrapper.vm.isLoaderDisplayed).toBe(false); }); + + it("Should set 'isLoaderDisplayed' to false when calling 'resetButtonStyle'", async () => { + // Arrange + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + loaderPosition: "right", + loaderEnabled: true, + }, + }) + ); + + wrapper.setData({ + isLoaderDisplayed: true + }); + + // Act + wrapper.vm.resetButtonStyle(); + await nextTick(); + + // Assert + expect(wrapper.vm.isLoaderDisplayed).toBe(false); + + }); + + it("Should emit 'click-event' event when clicking if the button is enabled", async () => { + // Arrange + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + loaderPosition: "right", + loaderEnabled: true, + isDisabled: false + }, + }) + ); + + + const buttonElement = wrapper.find("button"); + + // Act + buttonElement.trigger("click"); + + await nextTick(); + + // Assert + expect(wrapper.emitted("click-event")).toBeTruthy(); + + }); + + it("Should not emit 'click-event' event when clicking if the button is disabled", async () => { + // Arrange + const wrapper = shallowMount( + buttonMain, + setupMocks({ + props: { + loaderPosition: "right", + loaderEnabled: true, + isDisabled: true + }, + }) + ); + + const buttonElement = wrapper.find("button"); + + // Act + buttonElement.trigger("click"); + + await nextTick(); + + // Assert + expect(wrapper.emitted("click-event")).toBeFalsy(); + + }); }); function setupMocks(mountOptionsMockData = {}) { diff --git a/src/ux-components/button-main/button-main.vue b/src/ux-components/button-main/button-main.vue index 18d7427c2..41edc21cb 100644 --- a/src/ux-components/button-main/button-main.vue +++ b/src/ux-components/button-main/button-main.vue @@ -47,6 +47,7 @@ export default { true ); if (!this.isDisabled) { + console.log("I'm here"); this.isLoaderDisplayed = true; this.$emit("click-event"); }