2017-03-23 11:54:28 +00:00
|
|
|
import Vue from 'vue';
|
2019-11-26 21:06:38 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2017-04-18 15:29:22 +00:00
|
|
|
import Translate from '~/vue_shared/translate';
|
2019-11-26 21:06:38 +00:00
|
|
|
import LimitWarningComponent from '~/cycle_analytics/components/limit_warning_component.vue';
|
2017-03-23 11:54:28 +00:00
|
|
|
|
2017-04-18 15:29:22 +00:00
|
|
|
Vue.use(Translate);
|
|
|
|
|
2019-11-26 21:06:38 +00:00
|
|
|
const createComponent = props =>
|
|
|
|
shallowMount(LimitWarningComponent, {
|
|
|
|
propsData: {
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-03-23 11:54:28 +00:00
|
|
|
describe('Limit warning component', () => {
|
|
|
|
let component;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-11-26 21:06:38 +00:00
|
|
|
component = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
component.destroy();
|
2017-03-23 11:54:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render if count is not exactly than 50', () => {
|
2019-11-26 21:06:38 +00:00
|
|
|
component = createComponent({ count: 5 });
|
2017-03-23 11:54:28 +00:00
|
|
|
|
2019-11-26 21:06:38 +00:00
|
|
|
expect(component.text().trim()).toBe('');
|
2017-03-23 11:54:28 +00:00
|
|
|
|
2019-11-26 21:06:38 +00:00
|
|
|
component = createComponent({ count: 55 });
|
2017-03-23 11:54:28 +00:00
|
|
|
|
2019-11-26 21:06:38 +00:00
|
|
|
expect(component.text().trim()).toBe('');
|
2017-03-23 11:54:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render if count is exactly 50', () => {
|
2019-11-26 21:06:38 +00:00
|
|
|
component = createComponent({ count: 50 });
|
2017-03-23 11:54:28 +00:00
|
|
|
|
2019-11-26 21:06:38 +00:00
|
|
|
expect(component.text().trim()).toBe('Showing 50 events');
|
2017-03-23 11:54:28 +00:00
|
|
|
});
|
|
|
|
});
|