updated tests with latest date format

This commit is contained in:
Robert Elliott 2018-09-06 11:12:03 +02:00
parent b73f2ba47d
commit 0ad4b9a312
3 changed files with 133 additions and 75 deletions

View File

@ -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,
// },
// ];

View File

@ -1,76 +1,58 @@
/** @format */ /** @format */
// /** /**
// * /* eslint-disable quote-props * /* eslint-disable quote-props
// * *
// * @format * @format
// */ */
export default [ export default [
{ {
date: '2018-08-01T00:00:00', date: '2018-05-30T00:00:00',
'Custom (Aug 1, 2018)': 58929.99, Polo: 2704659,
'Previous Period (Jul 31, 2018)': 160130.74000000002, 'T-Shirt': 4499890,
Hoodie: 2159981,
Sunglasses: 3853788,
Cap: 10604510,
}, },
{ {
date: '2018-08-01T01:00:00', date: '2018-05-31T00:00:00',
'Custom (Aug 1, 2018)': 3805.56, Polo: 2027307,
'Previous Period (Jul 31, 2018)': 0, 'T-Shirt': 3277946,
Hoodie: 1420518,
Sunglasses: 2454721,
Cap: 7017731,
}, },
{ {
date: '2018-08-01T02:00:00', date: '2018-06-01T00:00:00',
'Custom (Aug 1, 2018)': 3805.56, Polo: 1208495,
'Previous Period (Jul 31, 2018)': 0, '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,
// },
// ];

View File

@ -57,12 +57,12 @@ const orderedKeys = [
}, },
]; ];
const orderedDates = [ const orderedDates = [
'2018-05-30', '2018-05-30T00:00:00',
'2018-05-31', '2018-05-31T00:00:00',
'2018-06-01', '2018-06-01T00:00:00',
'2018-06-02', '2018-06-02T00:00:00',
'2018-06-03', '2018-06-03T00:00:00',
'2018-06-04', '2018-06-04T00:00:00',
]; ];
const testUniqueKeys = getUniqueKeys( dummyOrders ); const testUniqueKeys = getUniqueKeys( dummyOrders );
const testOrderedKeys = getOrderedKeys( dummyOrders, testUniqueKeys ); const testOrderedKeys = getOrderedKeys( dummyOrders, testUniqueKeys );
@ -75,7 +75,7 @@ const testYScale = getYScale( 100, testYMax );
describe( 'parseDate', () => { describe( 'parseDate', () => {
it( 'correctly parse date in the expected format', () => { 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 ) ); const expectedDate = new Date( Date.UTC( 2018, 5, 30 ) );
expect( testDate.getTime() ).toEqual( expectedDate.getTime() ); expect( testDate.getTime() ).toEqual( expectedDate.getTime() );
} ); } );
@ -182,13 +182,13 @@ describe( 'getYTickOffset', () => {
describe( 'getdateSpaces', () => { describe( 'getdateSpaces', () => {
it( 'return an array used to space out the mouseover rectangles, used for tooltips', () => { it( 'return an array used to space out the mouseover rectangles, used for tooltips', () => {
const testDateSpaces = getDateSpaces( testUniqueDates, 100, testXLineScale ); 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 ].start ).toEqual( 0 );
expect( testDateSpaces[ 0 ].width ).toEqual( 10 ); 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 ].start ).toEqual( 50 );
expect( testDateSpaces[ 3 ].width ).toEqual( 20 ); 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 ].start ).toEqual( 90 );
expect( testDateSpaces[ testDateSpaces.length - 1 ].width ).toEqual( 10 ); expect( testDateSpaces[ testDateSpaces.length - 1 ].width ).toEqual( 10 );
} ); } );