Add validator and unit tests related to button type

This commit is contained in:
Alex Humphries 2026-02-27 12:58:13 -05:00
parent e1e7ee086e
commit 1cd6bdc432
2 changed files with 34 additions and 1 deletions

View file

@ -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');
});
});
});

View file

@ -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: {