Commit 5d106b4e authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Prepare limit_warning_component_spec for boostrap2

Minor refactor to vue-test-utils
parent c6ddde61
import Vue from 'vue'; import Vue from 'vue';
import { shallowMount } from '@vue/test-utils';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
import limitWarningComp from '~/cycle_analytics/components/limit_warning_component.vue'; import LimitWarningComponent from '~/cycle_analytics/components/limit_warning_component.vue';
Vue.use(Translate); Vue.use(Translate);
const createComponent = props =>
shallowMount(LimitWarningComponent, {
propsData: {
...props,
},
sync: false,
attachToDocument: true,
});
describe('Limit warning component', () => { describe('Limit warning component', () => {
let component; let component;
let LimitWarningComponent;
beforeEach(() => { beforeEach(() => {
LimitWarningComponent = Vue.extend(limitWarningComp); component = null;
});
afterEach(() => {
component.destroy();
}); });
it('should not render if count is not exactly than 50', () => { it('should not render if count is not exactly than 50', () => {
component = new LimitWarningComponent({ component = createComponent({ count: 5 });
propsData: {
count: 5,
},
}).$mount();
expect(component.$el.textContent.trim()).toBe(''); expect(component.text().trim()).toBe('');
component = new LimitWarningComponent({ component = createComponent({ count: 55 });
propsData: {
count: 55,
},
}).$mount();
expect(component.$el.textContent.trim()).toBe(''); expect(component.text().trim()).toBe('');
}); });
it('should render if count is exactly 50', () => { it('should render if count is exactly 50', () => {
component = new LimitWarningComponent({ component = createComponent({ count: 50 });
propsData: {
count: 50,
},
}).$mount();
expect(component.$el.textContent.trim()).toBe('Showing 50 events'); expect(component.text().trim()).toBe('Showing 50 events');
}); });
}); });
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