Commit 2751af68 authored by Martin Wortschack's avatar Martin Wortschack

Create UTC date

- Add tests for date column
parent 59feefb5
...@@ -33,7 +33,10 @@ export default { ...@@ -33,7 +33,10 @@ export default {
}, },
getDisplayValue(col) { getDisplayValue(col) {
if (col.isDate && col.value) { if (col.isDate && col.value) {
return dateInWords(new Date(col.value)); const [year, month, day] = col.value.split('-');
// create UTC date (prevent date from being converted to local timezone)
return dateInWords(new Date(year, month - 1, day));
} }
// let's display '-' instead of 0 for the 'Free' plan // let's display '-' instead of 0 for the 'Free' plan
......
---
title: Create UTC date in subscription table
merge_request: 9166
author:
type: fixed
import Vue from 'vue'; import Vue from 'vue';
import { dateInWords } from '~/lib/utils/datetime_utility';
import component from 'ee/billings/components/subscription_table_row.vue'; import component from 'ee/billings/components/subscription_table_row.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
...@@ -76,5 +77,28 @@ describe('Subscription Table Row', () => { ...@@ -76,5 +77,28 @@ describe('Subscription Table Row', () => {
expect(currentCol.querySelector('.btn-help')).not.toBe(null); expect(currentCol.querySelector('.btn-help')).not.toBe(null);
}); });
describe('date column', () => {
const dateColumn = {
id: 'c',
label: 'Column C',
value: '2018-01-31',
isDate: true,
};
beforeEach(() => {
props = { header, columns: [dateColumn] };
vm = mountComponent(Component, props);
});
it('should render the date in UTC', () => {
const currentCol = vm.$el.querySelectorAll('.grid-cell:not(.header-cell)')[0];
const d = dateColumn.value.split('-');
const outputDate = dateInWords(new Date(d[0], d[1] - 1, d[2]));
expect(currentCol.querySelector('.property-label').textContent).toContain(dateColumn.label);
expect(currentCol.querySelector('.property-value').textContent).toContain(outputDate);
});
});
}); });
}); });
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