Commit 2df9907e authored by Clement Ho's avatar Clement Ho

Merge branch 'prepare-cycle-analytics-specs-for-bootstrap-2' into 'master'

Prepare limit_warning_component_spec for boostrap2

See merge request gitlab-org/gitlab!20542
parents da271af2 5d106b4e
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