From 4b09eaf41e10799b9a3e5b313e6e62445158e8f9 Mon Sep 17 00:00:00 2001 From: mengxiong10 <15623530290@163.com> Date: Mon, 11 Nov 2019 10:53:38 +0800 Subject: [PATCH] test: fix snapshot inconsistency due to time zone --- .../__snapshots__/time-panel.test.js.snap | 258 +++++++------- .../__snapshots__/time-range.test.js.snap | 334 +++++++++--------- __test__/calendar-panel.test.js | 2 +- __test__/time-panel.test.js | 8 +- __test__/time-range.test.js | 5 +- 5 files changed, 305 insertions(+), 302 deletions(-) diff --git a/__test__/__snapshots__/time-panel.test.js.snap b/__test__/__snapshots__/time-panel.test.js.snap index 13c1bd4..cb76f66 100644 --- a/__test__/__snapshots__/time-panel.test.js.snap +++ b/__test__/__snapshots__/time-panel.test.js.snap @@ -77,7 +77,7 @@ exports[`TimePanel render: correct 12hours in the fixed time list 1`] = `
  • 12:30 PM @@ -302,7 +302,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • @@ -366,7 +366,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • @@ -421,7 +421,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = ` >
  • 00 @@ -429,7 +429,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 01 @@ -437,7 +437,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 02 @@ -445,7 +445,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 03 @@ -453,7 +453,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 04 @@ -461,7 +461,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 05 @@ -469,7 +469,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 06 @@ -477,7 +477,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 07 @@ -485,7 +485,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 08 @@ -493,7 +493,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 09 @@ -501,7 +501,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 10 @@ -509,7 +509,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 11 @@ -517,7 +517,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 12 @@ -525,7 +525,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 13 @@ -533,7 +533,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 14 @@ -541,7 +541,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 15 @@ -549,7 +549,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 16 @@ -557,7 +557,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 17 @@ -565,7 +565,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 18 @@ -573,7 +573,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 19 @@ -581,7 +581,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 20 @@ -589,7 +589,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 21 @@ -597,7 +597,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 22 @@ -605,7 +605,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 23 @@ -613,7 +613,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 24 @@ -621,7 +621,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 25 @@ -629,7 +629,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 26 @@ -637,7 +637,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 27 @@ -645,7 +645,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 28 @@ -653,7 +653,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 29 @@ -661,7 +661,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 30 @@ -669,7 +669,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 31 @@ -677,7 +677,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 32 @@ -685,7 +685,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 33 @@ -693,7 +693,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 34 @@ -701,7 +701,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 35 @@ -709,7 +709,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 36 @@ -717,7 +717,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 37 @@ -725,7 +725,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 38 @@ -733,7 +733,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 39 @@ -741,7 +741,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 40 @@ -749,7 +749,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 41 @@ -757,7 +757,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 42 @@ -765,7 +765,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 43 @@ -773,7 +773,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 44 @@ -781,7 +781,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 45 @@ -789,7 +789,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 46 @@ -797,7 +797,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 47 @@ -805,7 +805,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 48 @@ -813,7 +813,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 49 @@ -821,7 +821,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 50 @@ -829,7 +829,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 51 @@ -837,7 +837,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 52 @@ -845,7 +845,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 53 @@ -853,7 +853,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 54 @@ -861,7 +861,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 55 @@ -869,7 +869,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 56 @@ -877,7 +877,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 57 @@ -885,7 +885,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 58 @@ -893,7 +893,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 59 @@ -923,7 +923,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = ` >
  • 00 @@ -931,7 +931,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 01 @@ -939,7 +939,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 02 @@ -947,7 +947,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 03 @@ -955,7 +955,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 04 @@ -963,7 +963,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 05 @@ -971,7 +971,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 06 @@ -979,7 +979,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 07 @@ -987,7 +987,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 08 @@ -995,7 +995,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 09 @@ -1003,7 +1003,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 10 @@ -1011,7 +1011,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 11 @@ -1019,7 +1019,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 12 @@ -1027,7 +1027,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 13 @@ -1035,7 +1035,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 14 @@ -1043,7 +1043,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 15 @@ -1051,7 +1051,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 16 @@ -1059,7 +1059,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 17 @@ -1067,7 +1067,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 18 @@ -1075,7 +1075,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 19 @@ -1083,7 +1083,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 20 @@ -1091,7 +1091,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 21 @@ -1099,7 +1099,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 22 @@ -1107,7 +1107,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 23 @@ -1115,7 +1115,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 24 @@ -1123,7 +1123,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 25 @@ -1131,7 +1131,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 26 @@ -1139,7 +1139,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 27 @@ -1147,7 +1147,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 28 @@ -1155,7 +1155,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 29 @@ -1163,7 +1163,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 30 @@ -1171,7 +1171,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 31 @@ -1179,7 +1179,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 32 @@ -1187,7 +1187,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 33 @@ -1195,7 +1195,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 34 @@ -1203,7 +1203,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 35 @@ -1211,7 +1211,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 36 @@ -1219,7 +1219,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 37 @@ -1227,7 +1227,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 38 @@ -1235,7 +1235,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 39 @@ -1243,7 +1243,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 40 @@ -1251,7 +1251,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 41 @@ -1259,7 +1259,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 42 @@ -1267,7 +1267,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 43 @@ -1275,7 +1275,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 44 @@ -1283,7 +1283,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 45 @@ -1291,7 +1291,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 46 @@ -1299,7 +1299,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 47 @@ -1307,7 +1307,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 48 @@ -1315,7 +1315,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 49 @@ -1323,7 +1323,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 50 @@ -1331,7 +1331,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 51 @@ -1339,7 +1339,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 52 @@ -1347,7 +1347,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 53 @@ -1355,7 +1355,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 54 @@ -1363,7 +1363,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 55 @@ -1371,7 +1371,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 56 @@ -1379,7 +1379,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 57 @@ -1387,7 +1387,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 58 @@ -1395,7 +1395,7 @@ exports[`TimePanel render: correct classes of the columns 1`] = `
  • 59 @@ -1494,7 +1494,7 @@ exports[`TimePanel render: correct classes of the fixed time list 1`] = `
  • 12:30 @@ -1623,7 +1623,7 @@ exports[`TimePanel render: correct columns by format 1`] = ` data-type="hour" >
  • @@ -1678,7 +1678,7 @@ exports[`TimePanel render: correct columns by format 1`] = ` >
  • 00 @@ -1686,7 +1686,7 @@ exports[`TimePanel render: correct columns by format 1`] = `
  • 30 @@ -1716,7 +1716,7 @@ exports[`TimePanel render: correct columns by format 1`] = ` >
  • AM @@ -1724,7 +1724,7 @@ exports[`TimePanel render: correct columns by format 1`] = `
  • PM diff --git a/__test__/__snapshots__/time-range.test.js.snap b/__test__/__snapshots__/time-range.test.js.snap index 1fc95e6..34d8e87 100644 --- a/__test__/__snapshots__/time-range.test.js.snap +++ b/__test__/__snapshots__/time-range.test.js.snap @@ -4,166 +4,6 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
    -
    - - -
    -
    -
    -
    -
      -
    • - - 12 - -
    • -
    • - - 02 - -
    • -
    • - - 04 - -
    • -
    • - - 06 - -
    • -
    • - - 08 - -
    • -
    • - - 10 - -
    • -
    -
    - -
    -
    -
    -
    -
    -
    -
      -
    • - - 00 - -
    • -
    • - - 30 - -
    • -
    -
    - -
    -
    -
    -
    -
    -
    -
      -
    • - - AM - -
    • -
    • - - PM - -
    • -
    -
    - -
    -
    -
    -
    -
    -
    -
    @@ -203,7 +43,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
  • @@ -211,7 +51,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
  • @@ -258,7 +98,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = ` >
  • 00 @@ -266,7 +106,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
  • 30 @@ -295,8 +135,8 @@ exports[`TimeRange render: correct classes of the columns 1`] = ` data-type="ampm" >
  • AM @@ -304,7 +144,167 @@ exports[`TimeRange render: correct classes of the columns 1`] = `
  • + + PM + +
  • + + + +
    +
    +
    +
    + + + +
    + + +
    +
    +
    +
    +
      +
    • + + 12 + +
    • +
    • + + 02 + +
    • +
    • + + 04 + +
    • +
    • + + 06 + +
    • +
    • + + 08 + +
    • +
    • + + 10 + +
    • +
    +
    + +
    +
    +
    +
    +
    +
    +
      +
    • + + 00 + +
    • +
    • + + 30 + +
    • +
    +
    + +
    +
    +
    +
    +
    +
    +
      +
    • + + AM + +
    • +
    • PM diff --git a/__test__/calendar-panel.test.js b/__test__/calendar-panel.test.js index ddd439b..10c734c 100644 --- a/__test__/calendar-panel.test.js +++ b/__test__/calendar-panel.test.js @@ -56,7 +56,7 @@ describe('CalendarPanel', () => { wrapper = shallowMount(CalendarPanel, { propsData: { type, - value: new Date(2019, 9, 1, 10), + value: new Date(Date.UTC(2019, 9, 1, 10)), }, }); expect(wrapper.element).toMatchSnapshot(); diff --git a/__test__/time-panel.test.js b/__test__/time-panel.test.js index f109964..a8d4332 100644 --- a/__test__/time-panel.test.js +++ b/__test__/time-panel.test.js @@ -11,7 +11,7 @@ describe('TimePanel', () => { it('render: correct classes of the columns', () => { wrapper = mount(TimePanel, { propsData: { - value: new Date(2019, 9, 4, 12, 30, 30), + value: new Date(Date.UTC(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(2019, 9, 4), + value: new Date(Date.UTC(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(2019, 10, 9, 12, 30), + value: new Date(Date.UTC(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(2019, 10, 9, 12, 30), + value: new Date(Date.UTC(2019, 10, 9, 12, 30)), timePickerOptions: { start: '08:30', step: '00:30', diff --git a/__test__/time-range.test.js b/__test__/time-range.test.js index a0edba3..886ea62 100644 --- a/__test__/time-range.test.js +++ b/__test__/time-range.test.js @@ -14,7 +14,10 @@ describe('TimeRange', () => { format: 'hh:mm a', minuteStep: 30, hourStep: 2, - value: [new Date(2019, 9, 4, 8, 30, 0), new Date(2019, 9, 4, 18, 30, 0)], + value: [ + new Date(Date.UTC(2019, 9, 4, 8, 30, 0)), + new Date(Date.UTC(2019, 9, 4, 18, 30, 0)), + ], }, }); expect(wrapper.element).toMatchSnapshot();