From 1cd6bdc43292ae6e2b58a61fc0f153f7adaf857d Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Fri, 27 Feb 2026 12:58:13 -0500 Subject: [PATCH] Add validator and unit tests related to button type --- .../button-main/button-main.spec.js | 33 +++++++++++++++++++ src/ux-components/button-main/button-main.vue | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) 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: {