Commit f6c065c0 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'vs-migrate-total-time-to-vtu' into 'master'

Migrate cycle_analytics/total_time to VTU

See merge request gitlab-org/gitlab!57163
parents 4aa1e927 cefceea5
import Vue from 'vue'; import { shallowMount } from '@vue/test-utils';
import mountComponent from 'helpers/vue_mount_component_helper'; import TotalTime from '~/cycle_analytics/components/total_time_component.vue';
import component from '~/cycle_analytics/components/total_time_component.vue';
describe('Total time component', () => { describe('Total time component', () => {
let vm; let wrapper;
let Component;
beforeEach(() => { const createComponent = (propsData) => {
Component = Vue.extend(component); wrapper = shallowMount(TotalTime, {
}); propsData,
});
};
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
}); });
describe('With data', () => { describe('With data', () => {
it('should render information for days and hours', () => { it('should render information for days and hours', () => {
vm = mountComponent(Component, { createComponent({
time: { time: {
days: 3, days: 3,
hours: 4, hours: 4,
}, },
}); });
expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toEqual('3 days 4 hrs'); expect(wrapper.text()).toMatchInterpolatedText('3 days 4 hrs');
}); });
it('should render information for hours and minutes', () => { it('should render information for hours and minutes', () => {
vm = mountComponent(Component, { createComponent({
time: { time: {
hours: 4, hours: 4,
mins: 35, mins: 35,
}, },
}); });
expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toEqual('4 hrs 35 mins'); expect(wrapper.text()).toMatchInterpolatedText('4 hrs 35 mins');
}); });
it('should render information for seconds', () => { it('should render information for seconds', () => {
vm = mountComponent(Component, { createComponent({
time: { time: {
seconds: 45, seconds: 45,
}, },
}); });
expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toEqual('45 s'); expect(wrapper.text()).toMatchInterpolatedText('45 s');
}); });
}); });
describe('Without data', () => { describe('Without data', () => {
it('should render no information', () => { it('should render no information', () => {
vm = mountComponent(Component); createComponent();
expect(vm.$el.textContent.trim()).toEqual('--'); expect(wrapper.text()).toBe('--');
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment