2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-07 22:52:27 +03:00

test: fix snapshot inconsistency due to time zone

This commit is contained in:
mengxiong10
2019-11-11 11:16:09 +08:00
parent e2b24fa833
commit 0ff10e170a
6 changed files with 209 additions and 198 deletions
File diff suppressed because it is too large Load Diff
+34 -28
View File
@@ -24,11 +24,12 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
style="overflow: hidden scroll; height: 100%; margin-right: -0px;"
>
<ul
data-index="0"
data-type="hour"
>
<li
class="cell"
data-value="1570163400000"
data-index="0"
>
12
@@ -36,15 +37,15 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
</li>
<li
class="cell"
data-value="1570170600000"
data-index="1"
>
02
</li>
<li
class="cell active"
data-value="1570177800000"
class="cell"
data-index="2"
>
04
@@ -52,15 +53,15 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
</li>
<li
class="cell"
data-value="1570185000000"
data-index="3"
>
06
</li>
<li
class="cell"
data-value="1570192200000"
class="cell active"
data-index="4"
>
08
@@ -68,7 +69,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
</li>
<li
class="cell"
data-value="1570199400000"
data-index="5"
>
10
@@ -94,11 +95,12 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
style="overflow: hidden scroll; height: 100%; margin-right: -0px;"
>
<ul
data-index="1"
data-type="minute"
>
<li
class="cell"
data-value="1570176000000"
data-index="0"
>
00
@@ -106,7 +108,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
</li>
<li
class="cell active"
data-value="1570177800000"
data-index="1"
>
30
@@ -132,19 +134,20 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
style="overflow: hidden scroll; height: 100%; margin-right: -0px;"
>
<ul
data-index="2"
data-type="ampm"
>
<li
class="cell"
data-value="1570134600000"
class="cell active"
data-index="0"
>
AM
</li>
<li
class="cell active"
data-value="1570177800000"
class="cell"
data-index="1"
>
PM
@@ -184,19 +187,20 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
style="overflow: hidden scroll; height: 100%; margin-right: -0px;"
>
<ul
data-index="0"
data-type="hour"
>
<li
class="cell"
data-value="1570206600000"
data-index="0"
>
12
</li>
<li
class="cell active"
data-value="1570213800000"
class="cell"
data-index="1"
>
02
@@ -204,15 +208,15 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
</li>
<li
class="cell"
data-value="1570221000000"
data-index="2"
>
04
</li>
<li
class="cell"
data-value="1570228200000"
class="cell active"
data-index="3"
>
06
@@ -220,7 +224,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
</li>
<li
class="cell"
data-value="1570235400000"
data-index="4"
>
08
@@ -228,7 +232,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
</li>
<li
class="cell"
data-value="1570242600000"
data-index="5"
>
10
@@ -254,11 +258,12 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
style="overflow: hidden scroll; height: 100%; margin-right: -0px;"
>
<ul
data-index="1"
data-type="minute"
>
<li
class="cell"
data-value="1570212000000"
data-index="0"
>
00
@@ -266,7 +271,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
</li>
<li
class="cell active"
data-value="1570213800000"
data-index="1"
>
30
@@ -292,19 +297,20 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
style="overflow: hidden scroll; height: 100%; margin-right: -0px;"
>
<ul
data-index="2"
data-type="ampm"
>
<li
class="cell active"
data-value="1570213800000"
class="cell disabled"
data-index="0"
>
AM
</li>
<li
class="cell"
data-value="1570257000000"
class="cell active"
data-index="1"
>
PM
+1 -1
View File
@@ -56,7 +56,7 @@ describe('CalendarPanel', () => {
wrapper = shallowMount(CalendarPanel, {
propsData: {
type,
value: new Date(Date.UTC(2019, 9, 1, 10)),
value: new Date(2019, 9, 1, 10),
},
});
expect(wrapper.element).toMatchSnapshot();
+4 -4
View File
@@ -11,7 +11,7 @@ describe('TimePanel', () => {
it('render: correct classes of the columns', () => {
wrapper = mount(TimePanel, {
propsData: {
value: new Date(Date.UTC(2019, 9, 4, 12, 30, 30)),
value: new Date(2019, 9, 4, 12, 30, 30),
disabledTime: date => date.getHours() < 10,
},
});
@@ -21,7 +21,7 @@ describe('TimePanel', () => {
it('render: correct columns by format', () => {
wrapper = mount(TimePanel, {
propsData: {
value: new Date(Date.UTC(2019, 9, 4)),
value: new Date(2019, 9, 4),
format: 'hh:mm a',
minuteStep: 30,
hourOptions: Array.from({ length: 10 }).map((_, i) => i + 8),
@@ -33,7 +33,7 @@ describe('TimePanel', () => {
it('render: correct classes of the fixed time list', () => {
wrapper = mount(TimePanel, {
propsData: {
value: new Date(Date.UTC(2019, 10, 9, 12, 30)),
value: new Date(2019, 10, 9, 12, 30),
disabledTime: date => date.getHours() < 10,
timePickerOptions: {
start: '08:30',
@@ -49,7 +49,7 @@ describe('TimePanel', () => {
it('render: correct 12hours in the fixed time list', () => {
wrapper = mount(TimePanel, {
propsData: {
value: new Date(Date.UTC(2019, 10, 9, 12, 30)),
value: new Date(2019, 10, 9, 12, 30),
timePickerOptions: {
start: '08:30',
step: '00:30',
+1 -4
View File
@@ -14,10 +14,7 @@ describe('TimeRange', () => {
format: 'hh:mm a',
minuteStep: 30,
hourStep: 2,
value: [
new Date(Date.UTC(2019, 9, 4, 8, 30, 0)),
new Date(Date.UTC(2019, 9, 4, 18, 30, 0)),
],
value: [new Date(2019, 9, 4, 8, 30, 0), new Date(2019, 9, 4, 18, 30, 0)],
},
});
expect(wrapper.element).toMatchSnapshot();
+6 -4
View File
@@ -1,12 +1,12 @@
<template>
<div class="mx-time-columns">
<scrollbar-vertical v-for="(col, i) in columns" :key="i" class="mx-time-column">
<ul :data-type="col.type" @click="handleSelect">
<ul :data-type="col.type" :data-index="i" @click="handleSelect">
<li
v-for="item in col.list"
v-for="(item, j) in col.list"
:key="item.value"
class="cell"
:data-value="item.value"
:data-index="j"
:class="getClasses(item.value)"
>
{{ item.text }}
@@ -177,7 +177,9 @@ export default {
const { target, currentTarget } = evt;
if (target.tagName.toUpperCase() !== 'LI') return;
const type = currentTarget.getAttribute('data-type');
const value = parseInt(target.getAttribute('data-value'), 10);
const colIndex = parseInt(currentTarget.getAttribute('data-index'), 10);
const cellIndex = parseInt(target.getAttribute('data-index'), 10);
const { value } = this.columns[colIndex].list[cellIndex];
this.$emit('select', value, type);
},
},