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