Drop setProps usage

parent d703847e
...@@ -13,24 +13,22 @@ describe('ActionButton', () => { ...@@ -13,24 +13,22 @@ describe('ActionButton', () => {
const findButton = () => wrapper.findComponent(GlButton); const findButton = () => wrapper.findComponent(GlButton);
const findTooltip = () => wrapper.findComponent(GlTooltip); const findTooltip = () => wrapper.findComponent(GlTooltip);
const createComponent = () => { const createComponent = (props = {}) => {
wrapper = shallowMountExtended(ActionButton, { wrapper = shallowMountExtended(ActionButton, {
propsData: { propsData: {
actionType, actionType,
label, label,
...props,
}, },
}); });
}; };
beforeEach(() => {
createComponent();
});
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
it('renders a button with a tooltip attached', () => { it('renders a button with a tooltip attached', () => {
createComponent();
const button = findButton(); const button = findButton();
const tooltip = findTooltip(); const tooltip = findTooltip();
...@@ -40,11 +38,13 @@ describe('ActionButton', () => { ...@@ -40,11 +38,13 @@ describe('ActionButton', () => {
}); });
it('sets the label on the button and in the tooltip', () => { it('sets the label on the button and in the tooltip', () => {
createComponent();
expect(findButton().attributes('aria-label')).toBe(label); expect(findButton().attributes('aria-label')).toBe(label);
expect(findTooltip().text()).toBe(label); expect(findTooltip().text()).toBe(label);
}); });
it('emits bv::hide::tooltip and click events on click', () => { it('emits bv::hide::tooltip and click events on click', () => {
createComponent();
jest.spyOn(wrapper.vm.$root, '$emit'); jest.spyOn(wrapper.vm.$root, '$emit');
findButton().vm.$emit('click'); findButton().vm.$emit('click');
...@@ -52,10 +52,14 @@ describe('ActionButton', () => { ...@@ -52,10 +52,14 @@ describe('ActionButton', () => {
expect(wrapper.emitted('click')).toHaveLength(1); expect(wrapper.emitted('click')).toHaveLength(1);
}); });
it('passes the loading state down to the button', async () => { it('does not set the loading state by default', () => {
createComponent();
expect(findButton().props('loading')).toBe(false); expect(findButton().props('loading')).toBe(false);
});
await wrapper.setProps({ isLoading: true }); it('passes the loading state down to the button', async () => {
createComponent({ isLoading: true });
expect(findButton().props('loading')).toBe(true); expect(findButton().props('loading')).toBe(true);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment