Add validator and unit tests related to button type
This commit is contained in:
parent
e1e7ee086e
commit
1cd6bdc432
2 changed files with 34 additions and 1 deletions
|
|
@ -192,4 +192,37 @@ describe('buttonMain.vue', () => {
|
||||||
// Expect
|
// Expect
|
||||||
expect(spy).not.toHaveBeenCalled();
|
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');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ export default {
|
||||||
isOutline: Boolean,
|
isOutline: Boolean,
|
||||||
pushToGA: Boolean,
|
pushToGA: Boolean,
|
||||||
canOverride: { type: Boolean, required: false, default: true },
|
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'],
|
emits: ['click-event'],
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue