diff --git a/src/ux-components/button-main/button-main.spec.js b/src/ux-components/button-main/button-main.spec.js index c6825826..1f2b3863 100644 --- a/src/ux-components/button-main/button-main.spec.js +++ b/src/ux-components/button-main/button-main.spec.js @@ -192,4 +192,37 @@ describe('buttonMain.vue', () => { // Expect expect(spy).not.toHaveBeenCalled(); }); + + describe('Button Types', () => { + it('Should set button type to submit', async () => { + // Act + const wrapper = shallowMount( + buttonMain, + setupMocks({ + propsData: { + buttonType: 'submit' + } + }) + ); + + // Assert + const button = wrapper.find('button'); + + // Expect + expect(button.attributes('type')).toEqual('submit'); + }); + it('Should default button type to button', async () => { + // Act + const wrapper = shallowMount( + buttonMain, + setupMocks() + ); + + // Assert + const button = wrapper.find('button'); + + // Expect + expect(button.attributes('type')).toEqual('button'); + }); + }); }); diff --git a/src/ux-components/button-main/button-main.vue b/src/ux-components/button-main/button-main.vue index 7ffb7759..e88a4b74 100644 --- a/src/ux-components/button-main/button-main.vue +++ b/src/ux-components/button-main/button-main.vue @@ -23,7 +23,7 @@ export default { isOutline: Boolean, pushToGA: Boolean, canOverride: { type: Boolean, required: false, default: true }, - buttonType: { type: String, required: false, default: 'button' } + buttonType: { type: String, required: false, default: 'button', validator: (val) => ['button', 'submit', 'reset'].includes(val) } }, emits: ['click-event'], computed: {