summaryrefslogtreecommitdiffstats
path: root/test/generic-components
diff options
context:
space:
mode:
authorAdam Wudzinski <adam.wudzinski@nokia.com>2019-03-26 16:47:06 +0100
committerawudzins <adam.wudzinski@nokia.com>2019-03-26 16:47:06 +0100
commitb0f2f345cc2d1cc3812ad8a06fc1898daf5842d0 (patch)
treee6022e92e026a02912548e313ff2a02b5c27ddec /test/generic-components
parentb2c7546f9027099161aeaf5791f1d0f3a52b92d2 (diff)
Remove unused code
Remove unsed code from generic-components and change tests directory structure to reflect src structure Change-Id: Iada2efb0f7cfb05557eb7cd709b8a0ed75976b03 Issue-ID: AAI-1618 Signed-off-by: awudzins <adam.wudzinski@nokia.com>
Diffstat (limited to 'test/generic-components')
-rw-r--r--test/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.test.js40
-rw-r--r--test/generic-components/notifications/NotificationReducer.test.js197
-rw-r--r--test/generic-components/treeNode/TreeNode.test.js41
3 files changed, 40 insertions, 238 deletions
diff --git a/test/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.test.js b/test/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.test.js
new file mode 100644
index 0000000..7ba3d11
--- /dev/null
+++ b/test/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.test.js
@@ -0,0 +1,40 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+import {Provider} from 'react-redux'
+import configureStore from 'redux-mock-store';
+
+import AutoCompleteSearchBar from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx';
+
+describe('AutoCompleteSearchBarTests', () => {
+ const suggestions = [
+ {
+ text: 'Apple'
+ },
+ {
+ text: 'Orange'
+ },
+ {
+ text: 'Banana'
+ }
+ ];
+ const initialState = {
+ globalAutoCompleteSearchBarReducer: {
+ value: '',
+ suggestions: [],
+ cachedSuggestions: [],
+ suggestionName: ''
+ }
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = shallow(<Provider store={store}><AutoCompleteSearchBar /></Provider>);
+ })
+
+ it('render search bar - visible', () => {
+ expect(wrapper).toHaveLength(1); // ensure the message bar is mounted
+ expect(wrapper.find(AutoCompleteSearchBar)).toHaveLength(1); // ensure the InlineMessage is mounted
+ });
+})
diff --git a/test/generic-components/notifications/NotificationReducer.test.js b/test/generic-components/notifications/NotificationReducer.test.js
deleted file mode 100644
index 40d6b05..0000000
--- a/test/generic-components/notifications/NotificationReducer.test.js
+++ /dev/null
@@ -1,197 +0,0 @@
-import NotificationReducer from 'generic-components/notifications/NotificationReducer';
-import NotificationConstants from "generic-components/notifications/NotificationConstants";
-
-
-describe('NotificationReducer', () => {
- const defaultState = {
- type: 'default',
- title: 'some default title',
- msg: 'some default message',
- timeout: 1
- };
-
- it('Should return default state when action type is not supported', () => {
- // given
- const unsupportedAction = {
- type: undefined
- };
-
- // when
- const actualState = NotificationReducer(defaultState, unsupportedAction);
-
- // then
- expect(actualState).toEqual(defaultState);
- });
-
- it('Should return state with type default when action type is info', () => {
- // given
- const expectedState = {
- type: 'default',
- title: 'some title',
- msg: 'some message',
- timeout: 5
- };
-
- const infoAction = {
- type: NotificationConstants.NOTIFY_INFO,
- data: {
- title: "some title",
- msg: "some message",
- timeout: 5
- }
- };
-
- // when
- const actualState = NotificationReducer(defaultState, infoAction);
-
- // then
- expect(actualState).toEqual(expectedState);
- });
-
-
- it('Should return status with type success when action type is success', () => {
- // given
- const expectedState = {
- type: 'success',
- title: 'some title',
- msg: 'some message',
- timeout: 2
- };
-
- const infoAction = {
- type: NotificationConstants.NOTIFY_SUCCESS,
- data: {
- title: "some title",
- msg: "some message",
- timeout: 2
- }
- };
-
- // when
- const actualState = NotificationReducer(defaultState, infoAction);
-
- // then
- expect(actualState).toEqual(expectedState);
- });
-
- it('Should return status with type success when action type is success', () => {
- // given
- const expectedState = {
- type: 'success',
- title: 'some title',
- msg: 'some message',
- timeout: 2
- };
-
- const infoAction = {
- type: NotificationConstants.NOTIFY_SUCCESS,
- data: {
- title: "some title",
- msg: "some message",
- timeout: 2
- }
- };
-
- // when
- const actualState = NotificationReducer(defaultState, infoAction);
-
- // then
- expect(actualState).toEqual(expectedState);
- });
-
- it('Should return status with type error when action type is error', () => {
- // given
- const expectedState = {
- type: 'error',
- title: 'some title',
- msg: 'some message',
- timeout: 2
- };
-
- const infoAction = {
- type: NotificationConstants.NOTIFY_ERROR,
- data: {
- title: "some title",
- msg: "some message",
- timeout: 2
- }
- };
-
- // when
- const actualState = NotificationReducer(defaultState, infoAction);
-
- // then
- expect(actualState).toEqual(expectedState);
- });
-
- it('Should return status with type error when action type is error', () => {
- // given
- const expectedState = {
- type: 'error',
- title: 'some title',
- msg: 'some message',
- timeout: 2
- };
-
- const infoAction = {
- type: NotificationConstants.NOTIFY_ERROR,
- data: {
- title: "some title",
- msg: "some message",
- timeout: 2
- }
- };
-
- // when
- const actualState = NotificationReducer(defaultState, infoAction);
-
- // then
- expect(actualState).toEqual(expectedState);
- });
-
- it('Should return status with type warning when action type is warning', () => {
- // given
- const expectedState = {
- type: 'warning',
- title: 'some title',
- msg: 'some message',
- timeout: 2
- };
-
- const infoAction = {
- type: NotificationConstants.NOTIFY_WARNING,
- data: {
- title: "some title",
- msg: "some message",
- timeout: 2
- }
- };
-
- // when
- const actualState = NotificationReducer(defaultState, infoAction);
-
- // then
- expect(actualState).toEqual(expectedState);
- });
-
- it('Should return null when action type is close', () => {
- // given
- const expectedState = null;
-
- const infoAction = {
- type: NotificationConstants.NOTIFY_CLOSE,
- data: {
- title: "some title",
- msg: "some message",
- timeout: 2
- }
- };
-
- // when
- const actualState = NotificationReducer(defaultState, infoAction);
-
- // then
- expect(actualState).toEqual(expectedState);
- });
-
-});
diff --git a/test/generic-components/treeNode/TreeNode.test.js b/test/generic-components/treeNode/TreeNode.test.js
deleted file mode 100644
index 1c669e6..0000000
--- a/test/generic-components/treeNode/TreeNode.test.js
+++ /dev/null
@@ -1,41 +0,0 @@
-import TreeNode from 'generic-components/treeNode/TreeNode';
-import React from 'react';
-import { mount } from 'enzyme';
-
-describe('TreeNode', () => {
- let treeNode;
-
- beforeEach(() => {
- treeNode = mount(<TreeNode node={{title: 'AAA'}}/>).instance();
- });
-
-
- it('Should be invisible when created', () => {
- // then
- expect(treeNode.state['visible']).toEqual(false)
- });
-
- it('Should be visible when toggled', () => {
- // given
- expect(treeNode.state['visible']).toEqual(false)
-
- // when
- treeNode.toggle();
-
- // then
- expect(treeNode.state['visible']).toEqual(true)
- });
-
- it('Should be invisible when double toggled', () => {
- // given
- expect(treeNode.state['visible']).toEqual(false);
-
- // when
- treeNode.toggle();
- treeNode.toggle();
-
- // then
- expect(treeNode.state['visible']).toEqual(false);
- });
-
-});