debian-mirror-gitlab/spec/frontend/cycle_analytics/limit_warning_component_spec.js

42 lines
957 B
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2020-01-01 13:55:28 +05:30
import { shallowMount } from '@vue/test-utils';
2017-08-17 22:00:37 +05:30
import Translate from '~/vue_shared/translate';
2020-01-01 13:55:28 +05:30
import LimitWarningComponent from '~/cycle_analytics/components/limit_warning_component.vue';
2017-08-17 22:00:37 +05:30
Vue.use(Translate);
2020-01-01 13:55:28 +05:30
const createComponent = props =>
shallowMount(LimitWarningComponent, {
propsData: {
...props,
},
});
2017-08-17 22:00:37 +05:30
describe('Limit warning component', () => {
let component;
beforeEach(() => {
2020-01-01 13:55:28 +05:30
component = null;
});
afterEach(() => {
component.destroy();
2017-08-17 22:00:37 +05:30
});
it('should not render if count is not exactly than 50', () => {
2020-01-01 13:55:28 +05:30
component = createComponent({ count: 5 });
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
expect(component.text().trim()).toBe('');
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
component = createComponent({ count: 55 });
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
expect(component.text().trim()).toBe('');
2017-08-17 22:00:37 +05:30
});
it('should render if count is exactly 50', () => {
2020-01-01 13:55:28 +05:30
component = createComponent({ count: 50 });
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
expect(component.text().trim()).toBe('Showing 50 events');
2017-08-17 22:00:37 +05:30
});
});