X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Futils%2FSpinnerContainer.test.js;fp=src%2Futils%2FSpinnerContainer.test.js;h=a217b8a54ef505671ed00d6941751fe9246b8010;hb=0b2b11bad1457e7f388ab2a99af6ebf231e862e3;hp=0000000000000000000000000000000000000000;hpb=47b85e9b95e0a0a3570f0cea4d3ee4645c911a8b;p=aai%2Fsparky-fe.git diff --git a/src/utils/SpinnerContainer.test.js b/src/utils/SpinnerContainer.test.js new file mode 100644 index 0000000..a217b8a --- /dev/null +++ b/src/utils/SpinnerContainer.test.js @@ -0,0 +1,35 @@ +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( + +
Testing Spinner Child
+
Testing Spinner Child
+
+ ); + 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( + +
Testing Spinner
+
+ ); + 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); + }); +})