2021-04-29 21:17:54 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import TotalTime from '~/cycle_analytics/components/total_time_component.vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe('Total time component', () => {
|
2021-04-29 21:17:54 +05:30
|
|
|
let wrapper;
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
const createComponent = (propsData) => {
|
|
|
|
wrapper = shallowMount(TotalTime, {
|
|
|
|
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
|
|
|
});
|
|
|
|
|
|
|
|
describe('With data', () => {
|
|
|
|
it('should render information for days and hours', () => {
|
2021-04-29 21:17:54 +05:30
|
|
|
createComponent({
|
2018-03-17 18:26:18 +05:30
|
|
|
time: {
|
|
|
|
days: 3,
|
|
|
|
hours: 4,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(wrapper.text()).toMatchInterpolatedText('3 days 4 hrs');
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render information for hours and minutes', () => {
|
2021-04-29 21:17:54 +05:30
|
|
|
createComponent({
|
2018-03-17 18:26:18 +05:30
|
|
|
time: {
|
|
|
|
hours: 4,
|
|
|
|
mins: 35,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(wrapper.text()).toMatchInterpolatedText('4 hrs 35 mins');
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render information for seconds', () => {
|
2021-04-29 21:17:54 +05:30
|
|
|
createComponent({
|
2018-03-17 18:26:18 +05:30
|
|
|
time: {
|
|
|
|
seconds: 45,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(wrapper.text()).toMatchInterpolatedText('45 s');
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Without data', () => {
|
|
|
|
it('should render no information', () => {
|
2021-04-29 21:17:54 +05:30
|
|
|
createComponent();
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(wrapper.text()).toBe('--');
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|