+
+ describe('querySelectedNodeElement', () => {
+ const searchHash = "testHash";
+
+ it('emits actions when fetchRequest defined ', async () => {
+ // Given
+ const promise = () => getNodesPromise([]);
+ const expectedAction = [
+ {
+ type: tierSupportActionTypes.TIER_SUPPORT_ACTIVATE_BUSY_FEEDBACK,
+ },
+ {
+ type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS,
+ data: {errorMsg: NO_RESULTS_FOUND}
+ },
+ {
+ type: tierSupportActionTypes.TIER_SUPPORT_DISABLE_BUSY_FEEDBACK
+ }
+ ];
+
+ // When
+ await store.dispatch(querySelectedNodeElement(searchHash, promise));
+
+ // Then
+ expect(store.getActions()).toEqual(expectedAction);
+ });
+
+ it('builds request and emits actions when fetchRequest undefined ', async () => {
+ // Given
+ const stringifySpy = jest.spyOn(JSON, 'stringify');
+ const promise = getNodesPromise([]);
+ networkCall.fetchRequestObj = jest.fn(() => promise);
+ const expectedStringifyInput = {
+ hashId: searchHash
+ };
+ const expectedFetchRequestBody = "{\"hashId\":\"testHash\"}";
+ const expectedAction = [
+ {
+ type: tierSupportActionTypes.TIER_SUPPORT_ACTIVATE_BUSY_FEEDBACK,
+ },
+ {
+ type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS,
+ data: {errorMsg: NO_RESULTS_FOUND}
+ },
+ {
+ type: tierSupportActionTypes.TIER_SUPPORT_DISABLE_BUSY_FEEDBACK
+ }
+ ];
+
+ // When
+ await store.dispatch(querySelectedNodeElement(searchHash, undefined));
+
+ // Then
+ expect(stringifySpy).toHaveBeenCalledWith(expectedStringifyInput);
+ expect(networkCall.fetchRequestObj).toHaveBeenCalledWith(
+ expect.anything(),
+ expect.anything(),
+ expect.anything(),
+ expectedFetchRequestBody
+ );
+ expect(store.getActions()).toEqual(expectedAction);
+ });
+ });
+
+ describe('setNotificationText', () => {
+ const msgSeverity = MESSAGE_LEVEL_WARNING;
+
+ it('emits SET_GLOBAL_MESSAGE action with payload when msgText is not blank ', () => {
+ // Given
+ const msgText = 'some test text';
+ const expectedActions = [{
+ type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE,
+ data: {
+ msgText: msgText,
+ msgSeverity: msgSeverity
+ }
+ }];
+
+ // When
+ store.dispatch(setNotificationText(msgText, msgSeverity));
+
+ // Then
+ expect(store.getActions()).toEqual(expectedActions);
+ });
+
+ it('emits CLEAR_GLOBAL_MESSAGE when msgText is blank ', () => {
+ // Given
+ const msgText = '';
+ const expectedActions = [{
+ type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE
+ }];
+
+ // When
+ store.dispatch(setNotificationText(msgText, msgSeverity));
+
+ // Then
+ expect(store.getActions()).toEqual(expectedActions);
+ });
+ });
+
+ function getPromiseWithStatusCode(statusCode) {
+ return new Promise(function(resolve) {
+ resolve({status: statusCode});
+ });
+ }
+
+ function getNodesPromise(nodes) {
+ return new Promise(function (resolve) {
+ resolve({
+ status: 200,
+ json: () => {
+ return {
+ nodes: nodes
+ };
+ }
+ });
+ });
+ }
+
+ function prepareTestNodes() {
+ const node1 = prepareSelectedClassTestNode();
+ const node2 = prepareOtherClassTestNode();
+ return {
+ nodes: [node1, node2],
+ node1,
+ node2
+ }
+ }
+
+ function prepareOtherClassTestNode() {
+ return {
+ id: '3899453d98c5b670952765974876e55ef954e0f8a930b1c',
+ itemType: 'generic-vnf',
+ nodeMeta: {
+ className: 'someOtherClassName',
+ nodeLabel1: 'Artic',
+ nodeValidated: false,
+ nodeLocation: 'bottom'
+ },
+ rootNode: false,
+ index: 1
+ };
+ }
+
+ function prepareSelectedClassTestNode() {
+ return {
+ id: '7352312c7bfa814c3071a803d98c5b670952765974876e55ef954e0f8a930b1c',
+ itemType: 'complex',
+ nodeMeta: {
+ className: 'selectedSearchedNodeClass',
+ nodeLabel1: 'Artic',
+ nodeValidated: false,
+ nodeLocation: 'bottom'
+ },
+ rootNode: false,
+ index: 2
+ };
+ }
+});