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

46 lines
1,001 B
JavaScript
Raw Normal View History

2021-10-27 15:23:28 +05:30
import { mount } from '@vue/test-utils';
import TotalTimeComponent from '~/cycle_analytics/components/total_time_component.vue';
2018-03-17 18:26:18 +05:30
2021-10-27 15:23:28 +05:30
describe('TotalTimeComponent', () => {
let wrapper = null;
2018-03-17 18:26:18 +05:30
2021-04-29 21:17:54 +05:30
const createComponent = (propsData) => {
2021-10-27 15:23:28 +05:30
return mount(TotalTimeComponent, {
2021-04-29 21:17:54 +05:30
propsData,
});
};
2018-03-17 18:26:18 +05:30
afterEach(() => {
2021-04-29 21:17:54 +05:30
wrapper.destroy();
2018-03-17 18:26:18 +05:30
});
2021-10-27 15:23:28 +05:30
describe('with a valid time object', () => {
it.each`
time
${{ seconds: 35 }}
${{ mins: 47, seconds: 3 }}
${{ days: 3, mins: 47, seconds: 3 }}
${{ hours: 23, mins: 10 }}
${{ hours: 7, mins: 20, seconds: 10 }}
`('with $time', ({ time }) => {
wrapper = createComponent({
time,
2018-03-17 18:26:18 +05:30
});
2021-10-27 15:23:28 +05:30
expect(wrapper.html()).toMatchSnapshot();
2018-03-17 18:26:18 +05:30
});
2021-10-27 15:23:28 +05:30
});
2018-03-17 18:26:18 +05:30
2021-10-27 15:23:28 +05:30
describe('with a blank object', () => {
beforeEach(() => {
wrapper = createComponent({
time: {},
2018-03-17 18:26:18 +05:30
});
});
2021-10-27 15:23:28 +05:30
it('should render --', () => {
expect(wrapper.html()).toMatchSnapshot();
2018-03-17 18:26:18 +05:30
});
});
});