2017-10-06 04:29:24 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import component from '~/cycle_analytics/components/total_time_component.vue';
|
2018-02-26 14:43:34 -05:00
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2017-10-06 04:29:24 -04:00
|
|
|
|
|
|
|
describe('Total time component', () => {
|
|
|
|
let vm;
|
|
|
|
let Component;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Component = Vue.extend(component);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('With data', () => {
|
|
|
|
it('should render information for days and hours', () => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
time: {
|
|
|
|
days: 3,
|
|
|
|
hours: 4,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-01-09 06:58:34 -05:00
|
|
|
expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toEqual('3 days 4 hrs');
|
2017-10-06 04:29:24 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render information for hours and minutes', () => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
time: {
|
|
|
|
hours: 4,
|
|
|
|
mins: 35,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-01-09 06:58:34 -05:00
|
|
|
expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toEqual('4 hrs 35 mins');
|
2017-10-06 04:29:24 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render information for seconds', () => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
time: {
|
|
|
|
seconds: 45,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-01-09 06:58:34 -05:00
|
|
|
expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toEqual('45 s');
|
2017-10-06 04:29:24 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Without data', () => {
|
|
|
|
it('should render no information', () => {
|
|
|
|
vm = mountComponent(Component);
|
|
|
|
|
|
|
|
expect(vm.$el.textContent.trim()).toEqual('--');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|