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

42 lines
959 B
JavaScript
Raw Normal View History

2020-01-01 13:55:28 +05:30
import { shallowMount } from '@vue/test-utils';
2021-03-11 19:13:27 +05:30
import Vue from 'vue';
2020-01-01 13:55:28 +05:30
import LimitWarningComponent from '~/cycle_analytics/components/limit_warning_component.vue';
2021-03-11 19:13:27 +05:30
import Translate from '~/vue_shared/translate';
2017-08-17 22:00:37 +05:30
Vue.use(Translate);
2021-03-08 18:12:59 +05:30
const createComponent = (props) =>
2020-01-01 13:55:28 +05:30
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
});
});