From 0ad4b9a312432d7786c4b27b562903519e3ae1cb Mon Sep 17 00:00:00 2001 From: Robert Elliott Date: Thu, 6 Sep 2018 11:12:03 +0200 Subject: [PATCH] updated tests with latest date format --- .../chart/test/fixtures/dummy-hour.js | 76 ++++++++++++ .../components/chart/test/fixtures/dummy.js | 112 ++++++++---------- .../client/components/chart/test/utils.js | 20 ++-- 3 files changed, 133 insertions(+), 75 deletions(-) create mode 100644 plugins/woocommerce-admin/client/components/chart/test/fixtures/dummy-hour.js diff --git a/plugins/woocommerce-admin/client/components/chart/test/fixtures/dummy-hour.js b/plugins/woocommerce-admin/client/components/chart/test/fixtures/dummy-hour.js new file mode 100644 index 00000000000..e745cb20b53 --- /dev/null +++ b/plugins/woocommerce-admin/client/components/chart/test/fixtures/dummy-hour.js @@ -0,0 +1,76 @@ +/** @format */ + +// /** +// * /* eslint-disable quote-props +// * +// * @format +// */ + +export default [ + { + date: '2018-08-01T00:00:00', + 'Custom (Aug 1, 2018)': 58929.99, + 'Previous Period (Jul 31, 2018)': 160130.74000000002, + }, + { + date: '2018-08-01T01:00:00', + 'Custom (Aug 1, 2018)': 3805.56, + 'Previous Period (Jul 31, 2018)': 0, + }, + { + date: '2018-08-01T02:00:00', + 'Custom (Aug 1, 2018)': 3805.56, + 'Previous Period (Jul 31, 2018)': 0, + }, +]; + +// export default [ +// { +// date: '2018-05-30', +// Polo: 2704659, +// 'T-Shirt': 4499890, +// Hoodie: 2159981, +// Sunglasses: 3853788, +// Cap: 10604510, +// }, +// { +// date: '2018-05-31', +// Polo: 2027307, +// 'T-Shirt': 3277946, +// Hoodie: 1420518, +// Sunglasses: 2454721, +// Cap: 7017731, +// }, +// { +// date: '2018-06-01', +// Polo: 1208495, +// 'T-Shirt': 2141490, +// Hoodie: 1058031, +// Sunglasses: 1999120, +// Cap: 5355235, +// }, +// { +// date: '2018-06-02', +// Polo: 1140516, +// 'T-Shirt': 1938695, +// Hoodie: 925060, +// Sunglasses: 1607297, +// Cap: 4782119, +// }, +// { +// date: '2018-06-03', +// Polo: 894368, +// 'T-Shirt': 1558919, +// Hoodie: 725973, +// Sunglasses: 1311479, +// Cap: 3596343, +// }, +// { +// date: '2018-06-04', +// Polo: 737462, +// 'T-Shirt': 1345341, +// Hoodie: 679201, +// Sunglasses: 1203944, +// Cap: 3157759, +// }, +// ]; diff --git a/plugins/woocommerce-admin/client/components/chart/test/fixtures/dummy.js b/plugins/woocommerce-admin/client/components/chart/test/fixtures/dummy.js index e745cb20b53..21994d98cb5 100644 --- a/plugins/woocommerce-admin/client/components/chart/test/fixtures/dummy.js +++ b/plugins/woocommerce-admin/client/components/chart/test/fixtures/dummy.js @@ -1,76 +1,58 @@ /** @format */ -// /** -// * /* eslint-disable quote-props -// * -// * @format -// */ +/** + * /* eslint-disable quote-props + * + * @format + */ export default [ { - date: '2018-08-01T00:00:00', - 'Custom (Aug 1, 2018)': 58929.99, - 'Previous Period (Jul 31, 2018)': 160130.74000000002, + date: '2018-05-30T00:00:00', + Polo: 2704659, + 'T-Shirt': 4499890, + Hoodie: 2159981, + Sunglasses: 3853788, + Cap: 10604510, }, { - date: '2018-08-01T01:00:00', - 'Custom (Aug 1, 2018)': 3805.56, - 'Previous Period (Jul 31, 2018)': 0, + date: '2018-05-31T00:00:00', + Polo: 2027307, + 'T-Shirt': 3277946, + Hoodie: 1420518, + Sunglasses: 2454721, + Cap: 7017731, }, { - date: '2018-08-01T02:00:00', - 'Custom (Aug 1, 2018)': 3805.56, - 'Previous Period (Jul 31, 2018)': 0, + date: '2018-06-01T00:00:00', + Polo: 1208495, + 'T-Shirt': 2141490, + Hoodie: 1058031, + Sunglasses: 1999120, + Cap: 5355235, + }, + { + date: '2018-06-02T00:00:00', + Polo: 1140516, + 'T-Shirt': 1938695, + Hoodie: 925060, + Sunglasses: 1607297, + Cap: 4782119, + }, + { + date: '2018-06-03T00:00:00', + Polo: 894368, + 'T-Shirt': 1558919, + Hoodie: 725973, + Sunglasses: 1311479, + Cap: 3596343, + }, + { + date: '2018-06-04T00:00:00', + Polo: 737462, + 'T-Shirt': 1345341, + Hoodie: 679201, + Sunglasses: 1203944, + Cap: 3157759, }, ]; - -// export default [ -// { -// date: '2018-05-30', -// Polo: 2704659, -// 'T-Shirt': 4499890, -// Hoodie: 2159981, -// Sunglasses: 3853788, -// Cap: 10604510, -// }, -// { -// date: '2018-05-31', -// Polo: 2027307, -// 'T-Shirt': 3277946, -// Hoodie: 1420518, -// Sunglasses: 2454721, -// Cap: 7017731, -// }, -// { -// date: '2018-06-01', -// Polo: 1208495, -// 'T-Shirt': 2141490, -// Hoodie: 1058031, -// Sunglasses: 1999120, -// Cap: 5355235, -// }, -// { -// date: '2018-06-02', -// Polo: 1140516, -// 'T-Shirt': 1938695, -// Hoodie: 925060, -// Sunglasses: 1607297, -// Cap: 4782119, -// }, -// { -// date: '2018-06-03', -// Polo: 894368, -// 'T-Shirt': 1558919, -// Hoodie: 725973, -// Sunglasses: 1311479, -// Cap: 3596343, -// }, -// { -// date: '2018-06-04', -// Polo: 737462, -// 'T-Shirt': 1345341, -// Hoodie: 679201, -// Sunglasses: 1203944, -// Cap: 3157759, -// }, -// ]; diff --git a/plugins/woocommerce-admin/client/components/chart/test/utils.js b/plugins/woocommerce-admin/client/components/chart/test/utils.js index 313d4c65cd4..12a54cbf960 100644 --- a/plugins/woocommerce-admin/client/components/chart/test/utils.js +++ b/plugins/woocommerce-admin/client/components/chart/test/utils.js @@ -57,12 +57,12 @@ const orderedKeys = [ }, ]; const orderedDates = [ - '2018-05-30', - '2018-05-31', - '2018-06-01', - '2018-06-02', - '2018-06-03', - '2018-06-04', + '2018-05-30T00:00:00', + '2018-05-31T00:00:00', + '2018-06-01T00:00:00', + '2018-06-02T00:00:00', + '2018-06-03T00:00:00', + '2018-06-04T00:00:00', ]; const testUniqueKeys = getUniqueKeys( dummyOrders ); const testOrderedKeys = getOrderedKeys( dummyOrders, testUniqueKeys ); @@ -75,7 +75,7 @@ const testYScale = getYScale( 100, testYMax ); describe( 'parseDate', () => { it( 'correctly parse date in the expected format', () => { - const testDate = parseDate( '2018-06-30' ); + const testDate = parseDate( '2018-06-30T00:00:00' ); const expectedDate = new Date( Date.UTC( 2018, 5, 30 ) ); expect( testDate.getTime() ).toEqual( expectedDate.getTime() ); } ); @@ -182,13 +182,13 @@ describe( 'getYTickOffset', () => { describe( 'getdateSpaces', () => { it( 'return an array used to space out the mouseover rectangles, used for tooltips', () => { const testDateSpaces = getDateSpaces( testUniqueDates, 100, testXLineScale ); - expect( testDateSpaces[ 0 ].date ).toEqual( '2018-05-30' ); + expect( testDateSpaces[ 0 ].date ).toEqual( '2018-05-30T00:00:00' ); expect( testDateSpaces[ 0 ].start ).toEqual( 0 ); expect( testDateSpaces[ 0 ].width ).toEqual( 10 ); - expect( testDateSpaces[ 3 ].date ).toEqual( '2018-06-02' ); + expect( testDateSpaces[ 3 ].date ).toEqual( '2018-06-02T00:00:00' ); expect( testDateSpaces[ 3 ].start ).toEqual( 50 ); expect( testDateSpaces[ 3 ].width ).toEqual( 20 ); - expect( testDateSpaces[ testDateSpaces.length - 1 ].date ).toEqual( '2018-06-04' ); + expect( testDateSpaces[ testDateSpaces.length - 1 ].date ).toEqual( '2018-06-04T00:00:00' ); expect( testDateSpaces[ testDateSpaces.length - 1 ].start ).toEqual( 90 ); expect( testDateSpaces[ testDateSpaces.length - 1 ].width ).toEqual( 10 ); } );