summaryrefslogtreecommitdiffstats
path: root/test/utils/SpinnerContainer.test.js
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 /test/utils/SpinnerContainer.test.js
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 'test/utils/SpinnerContainer.test.js')
-rw-r--r--test/utils/SpinnerContainer.test.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/utils/SpinnerContainer.test.js b/test/utils/SpinnerContainer.test.js
new file mode 100644
index 0000000..088ad2a
--- /dev/null
+++ b/test/utils/SpinnerContainer.test.js
@@ -0,0 +1,35 @@
+import React from 'react';
+import { ClipLoader } from 'react-spinners';
+import { mount } from 'enzyme';
+
+import SpinnerContainer from 'utils/SpinnerContainer.jsx';
+import {COLOR_BLUE} from 'utils/GlobalConstants';
+
+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);
+ });
+})