summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorArul.Nambi <arul.nambi@amdocs.com>2018-07-11 14:19:41 -0400
committerArul.Nambi <arul.nambi@amdocs.com>2018-07-16 10:04:10 -0400
commit75597ac2b51ba62bee33f72a7b55a549cf43a16f (patch)
tree9e9b6826a51abbdd011e5449c4812e8cca6d58a1 /src/utils
parent4cbfb73eebc578c62ff38c82f969782e229ce969 (diff)
Refactoring test scripts
Moving the test scripts under one folder and restucting them so that the clutter can be avoided in the src folder. Issue-ID: AAI-1371 Change-Id: I41b34acbe79a7a3409f2990f11492614f7ef9c5a Signed-off-by: Arul.Nambi <arul.nambi@amdocs.com>
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/DateTimeChartUtil.test.js92
-rw-r--r--src/utils/SpinnerContainer.test.js35
2 files changed, 0 insertions, 127 deletions
diff --git a/src/utils/DateTimeChartUtil.test.js b/src/utils/DateTimeChartUtil.test.js
deleted file mode 100644
index b1e9d69..0000000
--- a/src/utils/DateTimeChartUtil.test.js
+++ /dev/null
@@ -1,92 +0,0 @@
-import {
- sortDataByField,
- dateFormatLocalTimeZoneMMDDYYYY,
- dateFormatLocalTimeZoneYYYYMMDD,
- getTicks,
- getTicksData
-} from './DateTimeChartUtil.js';
-
-describe('DateTimeChartUtil Tests', () => {
- it('sortDataByField', () => {
- let initialData = [
- {word: 'plum', number: 2},
- {word: 'apple', number: 3},
- {word: 'banana', number: 1}
- ];
-
- sortDataByField(initialData, 'number');
- expect(initialData[0]['number']).toBe(1);
- expect(initialData[0]['word']).toBe('banana');
- expect(initialData[1]['number']).toBe(2);
- expect(initialData[1]['word']).toBe('plum');
- expect(initialData[2]['number']).toBe(3);
- expect(initialData[2]['word']).toBe('apple');
- });
-
- it('dateFormatLocalTimeZoneMMDDYYYY', () => {
- const timestamp = Date.parse('Mon, 25 Dec 1995 13:30:00 GMT');
- let formattedDate = dateFormatLocalTimeZoneMMDDYYYY(timestamp);
- expect(formattedDate).toBe('12/25/1995');
- });
-
- it('dateFormatLocalTimeZoneYYYYMMDD', () => {
- const timestamp = Date.parse('Mon, 25 Dec 1995 13:30:00 GMT');
- let formattedDate = dateFormatLocalTimeZoneYYYYMMDD(timestamp);
- expect(formattedDate).toBe('1995-12-25');
- });
-
- it('getTicks', () => {
- const timestamps = [
- {timestamp: 1521691200000, date: 'Thu, 22 Mar 2018 04:00:00 GMT'},
- {timestamp: 1521777600000, date: 'Thu, 23 Mar 2018 04:00:00 GMT'},
- {timestamp: 1521950400000, date: 'Thu, 25 Mar 2018 04:00:00 GMT'},
- {timestamp: 1522296000000, date: 'Thu, 29 Mar 2018 04:00:00 GMT'}
- ];
- let ticksPerDay = getTicks(timestamps, 'timestamp');
- // expect 1 tick (timestamp) for each day between March 22 - March 29
- expect(ticksPerDay.length).toBe(8);
- });
-
- it('getTicks - empty data', () => {
- const timestamps = [];
- let ticksPerDay = getTicks(timestamps, 'timestamp');
- expect(ticksPerDay.length).toBe(0);
- });
-
- it('getTicksData', () => {
- const timestamps = [
- {timestamp: 1521691200000, date: 'Thu, 22 Mar 2018 04:00:00 GMT'},
- {timestamp: 1521777600000, date: 'Thu, 23 Mar 2018 04:00:00 GMT'},
- {timestamp: 1521950400000, date: 'Thu, 25 Mar 2018 04:00:00 GMT'},
- {timestamp: 1522296000000, date: 'Thu, 29 Mar 2018 04:00:00 GMT'}
- ];
- let ticksPerDay = getTicks(timestamps, 'timestamp');
- let mergedData = getTicksData(timestamps, ticksPerDay, 'timestamp');
- // expect original 4 objects plus 4 additional objects for the missing days
- // (4 additional objects will only have timestamp attribute, no date attribute)
- expect(mergedData.length).toBe(8);
- expect(mergedData[0]['timestamp']).toBe(1521691200000);
- expect(mergedData[0]['date']).toBe('Thu, 22 Mar 2018 04:00:00 GMT');
- expect(mergedData[1]['timestamp']).toBe(1521777600000);
- expect(mergedData[1]['date']).toBe('Thu, 23 Mar 2018 04:00:00 GMT');
- expect(mergedData[2]['timestamp']).toBe(1521950400000);
- expect(mergedData[2]['date']).toBe('Thu, 25 Mar 2018 04:00:00 GMT');
- expect(mergedData[3]['timestamp']).toBe(1522296000000);
- expect(mergedData[3]['date']).toBe('Thu, 29 Mar 2018 04:00:00 GMT');
- expect(mergedData[4]['timestamp']).toBeTruthy();
- expect(mergedData[4]['date']).toBeUndefined();
- expect(mergedData[5]['timestamp']).toBeTruthy();
- expect(mergedData[5]['date']).toBeUndefined();
- expect(mergedData[6]['timestamp']).toBeTruthy();
- expect(mergedData[6]['date']).toBeUndefined();
- expect(mergedData[7]['timestamp']).toBeTruthy();
- expect(mergedData[7]['date']).toBeUndefined();
- });
-
- it('getTicksData - empty data', () => {
- const timestamps = [];
- let ticksPerDay = getTicks(timestamps, 'timestamp');
- let mergedData = getTicksData(timestamps, ticksPerDay, 'timestamp');
- expect(mergedData.length).toBe(0);
- });
-})
diff --git a/src/utils/SpinnerContainer.test.js b/src/utils/SpinnerContainer.test.js
deleted file mode 100644
index a217b8a..0000000
--- a/src/utils/SpinnerContainer.test.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import React from 'react';
-import { ClipLoader } from 'react-spinners';
-import { mount } from 'enzyme';
-
-import SpinnerContainer from './SpinnerContainer.jsx';
-import {COLOR_BLUE} from 'utils/GlobalConstants.js';
-
-describe('SpinnerContainer', () => {
- it('render spinner - visible', () => {
- const spinner = mount(
- <SpinnerContainer loading={true}>
- <div class='test-div'>Testing Spinner Child</div>
- <div class='test-div'>Testing Spinner Child</div>
- </SpinnerContainer>
- );
- expect(spinner.props().loading).toEqual(true); // check that the props match
- expect(spinner.find(ClipLoader)).toHaveLength(1); // ensure the ClipLoader is mounted
- expect(spinner.find(ClipLoader).props().color).toEqual(COLOR_BLUE); // ensure spinner is blue
- expect(spinner.find(ClipLoader).props().loading).toEqual(true); // ensure spinner is showing
- expect(spinner.find('div.spinner-content')).toHaveLength(1); // ensure the children are grayed out
- expect(spinner.find('div.spinner-content').children()).toHaveLength(2); // ensure number of children is accurate
- });
-
- it('render spinner - not visible', () => {
- const spinner = mount(
- <SpinnerContainer loading={false}>
- <div class='test-div'>Testing Spinner</div>
- </SpinnerContainer>
- );
- expect(spinner.props().loading).toEqual(false);
- expect(spinner.find(ClipLoader)).toHaveLength(1);
- expect(spinner.find(ClipLoader).props().loading).toEqual(false); // ensure spinner is not showing
- expect(spinner.find('div.spinner-content')).toHaveLength(0);
- });
-})