diff --git a/src/tests/services/actions/adaptive-cards-action-creator.spec.ts b/src/app/services/actions/adaptive-cards-action-creator.spec.ts similarity index 100% rename from src/tests/services/actions/adaptive-cards-action-creator.spec.ts rename to src/app/services/actions/adaptive-cards-action-creator.spec.ts diff --git a/src/tests/services/actions/auth-action-creators.spec.ts b/src/app/services/actions/auth-action-creators.spec.ts similarity index 100% rename from src/tests/services/actions/auth-action-creators.spec.ts rename to src/app/services/actions/auth-action-creators.spec.ts diff --git a/src/tests/services/actions/autocomplete-action-creators.spec.ts b/src/app/services/actions/autocomplete-action-creators.spec.ts similarity index 100% rename from src/tests/services/actions/autocomplete-action-creators.spec.ts rename to src/app/services/actions/autocomplete-action-creators.spec.ts diff --git a/src/tests/services/actions/devxApi-action-creators.spec.ts b/src/app/services/actions/devxApi-action-creators.spec.ts similarity index 100% rename from src/tests/services/actions/devxApi-action-creators.spec.ts rename to src/app/services/actions/devxApi-action-creators.spec.ts diff --git a/src/tests/services/actions/dimensions-action-creator.spec.ts b/src/app/services/actions/dimensions-action-creator.spec.ts similarity index 100% rename from src/tests/services/actions/dimensions-action-creator.spec.ts rename to src/app/services/actions/dimensions-action-creator.spec.ts diff --git a/src/tests/services/actions/graph-explorer-mode.spec.ts b/src/app/services/actions/explorer-mode-action-creator.spec.ts similarity index 77% rename from src/tests/services/actions/graph-explorer-mode.spec.ts rename to src/app/services/actions/explorer-mode-action-creator.spec.ts index 0c9426e49..55840372f 100644 --- a/src/tests/services/actions/graph-explorer-mode.spec.ts +++ b/src/app/services/actions/explorer-mode-action-creator.spec.ts @@ -1,8 +1,8 @@ import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; -import { setGraphExplorerMode } from '../../../app/services/actions/explorer-mode-action-creator'; -import { SET_GRAPH_EXPLORER_MODE_SUCCESS } from '../../../app/services/redux-constants'; +import { setGraphExplorerMode } from './explorer-mode-action-creator'; +import { SET_GRAPH_EXPLORER_MODE_SUCCESS } from '../redux-constants'; import { Mode } from '../../../types/enums'; const middlewares = [thunk]; diff --git a/src/tests/services/actions/ocps-action-creators.spec.ts b/src/app/services/actions/ocps-action-creators.spec.ts similarity index 100% rename from src/tests/services/actions/ocps-action-creators.spec.ts rename to src/app/services/actions/ocps-action-creators.spec.ts diff --git a/src/tests/services/actions/permissions-action-creators.spec.ts b/src/app/services/actions/permissions-action-creator.spec.ts similarity index 96% rename from src/tests/services/actions/permissions-action-creators.spec.ts rename to src/app/services/actions/permissions-action-creator.spec.ts index 94ad3a7bf..e4af12e29 100644 --- a/src/tests/services/actions/permissions-action-creators.spec.ts +++ b/src/app/services/actions/permissions-action-creator.spec.ts @@ -3,18 +3,18 @@ import { FETCH_SCOPES_PENDING, FETCH_SCOPES_SUCCESS, QUERY_GRAPH_STATUS -} from '../../../app/services/redux-constants'; +} from '../redux-constants'; import { fetchScopesSuccess, fetchScopesPending, fetchScopesError, getPermissionsScopeType, fetchScopes, consentToScopes } from - '../../../app/services/actions/permissions-action-creator'; + './permissions-action-creator'; import { IPermissionsResponse } from '../../../types/permissions'; import thunk from 'redux-thunk'; import configureMockStore from 'redux-mock-store'; import fetch from 'jest-fetch-mock'; -import { store } from '../../../../src/store/index'; +import { store } from '../../../store/index'; import { IRootState } from '../../../types/root'; import { Mode } from '../../../types/enums'; const middleware = [thunk]; diff --git a/src/tests/services/actions/permissions-panel-action-creators.spec.ts b/src/app/services/actions/permissions-panel-action-creator.spec.ts similarity index 67% rename from src/tests/services/actions/permissions-panel-action-creators.spec.ts rename to src/app/services/actions/permissions-panel-action-creator.spec.ts index 8ee592026..12442098a 100644 --- a/src/tests/services/actions/permissions-panel-action-creators.spec.ts +++ b/src/app/services/actions/permissions-panel-action-creator.spec.ts @@ -1,5 +1,5 @@ -import { PERMISSIONS_PANEL_OPEN } from '../../../app/services/redux-constants'; -import { togglePermissionsPanel } from '../../../app/services/actions/permissions-panel-action-creator'; +import { PERMISSIONS_PANEL_OPEN } from '../redux-constants'; +import { togglePermissionsPanel } from './permissions-panel-action-creator'; describe('Tests permissions panel action creator', () => { it('tests permissions panel action creator', () => { diff --git a/src/tests/services/actions/profile-action-creators.spec.tsx b/src/app/services/actions/profile-action-creators.spec.ts similarity index 87% rename from src/tests/services/actions/profile-action-creators.spec.tsx rename to src/app/services/actions/profile-action-creators.spec.ts index 2d0dce0f4..b65639f1f 100644 --- a/src/tests/services/actions/profile-action-creators.spec.tsx +++ b/src/app/services/actions/profile-action-creators.spec.ts @@ -1,11 +1,14 @@ import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; -import { getProfileInfo, profileRequestError, getProfileInformation, +import { + getProfileInfo, profileRequestError, getProfileInformation, profileRequestSuccess, getBetaProfile, getProfileType, - getProfileImage, getProfileResponse } from '../../../app/services/actions/profile-action-creators'; + getProfileImage, getProfileResponse +} from './profile-action-creators'; import { - PROFILE_REQUEST_ERROR, PROFILE_REQUEST_SUCCESS} from '../../../app/services/redux-constants'; + PROFILE_REQUEST_ERROR, PROFILE_REQUEST_SUCCESS +} from '../redux-constants'; const middlewares = [thunk]; const mockStore = configureMockStore(middlewares); @@ -35,7 +38,7 @@ describe('actions', () => { const includesError = store.getActions().filter(k => k.type === PROFILE_REQUEST_ERROR) expect(!!includesError).toEqual(true); }) - .catch( (e : Error) => { throw e}) + .catch((e: Error) => { throw e }) }); it('dispatches PROFILE_REQUEST_ERROR if profile request fails', () => { diff --git a/src/tests/services/actions/proxy-action-creator.spec.ts b/src/app/services/actions/proxy-action-creator.spec.ts similarity index 100% rename from src/tests/services/actions/proxy-action-creator.spec.ts rename to src/app/services/actions/proxy-action-creator.spec.ts diff --git a/src/tests/services/actions/query-action-creators.spec.tsx b/src/app/services/actions/query-action-creators.spec.ts similarity index 94% rename from src/tests/services/actions/query-action-creators.spec.tsx rename to src/app/services/actions/query-action-creators.spec.ts index 837a589d6..6e300bd83 100644 --- a/src/tests/services/actions/query-action-creators.spec.tsx +++ b/src/app/services/actions/query-action-creators.spec.ts @@ -2,8 +2,8 @@ import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; -import { runQuery } from '../../../app/services/actions/query-action-creators'; -import { QUERY_GRAPH_RUNNING, QUERY_GRAPH_STATUS, QUERY_GRAPH_SUCCESS } from '../../../app/services/redux-constants'; +import { runQuery } from './query-action-creators'; +import { QUERY_GRAPH_RUNNING, QUERY_GRAPH_STATUS, QUERY_GRAPH_SUCCESS } from '../redux-constants'; const middlewares = [thunk]; const mockStore = configureMockStore(middlewares); @@ -68,7 +68,7 @@ describe('query actions', () => { .then(() => { expect(store.getActions()[0]).toEqual(expectedActions[0]); }) - .catch((e : Error) => { throw e}); + .catch((e: Error) => { throw e }); }); it('dispatches QUERY_GRAPH_STATUS for failed requests', () => { @@ -127,6 +127,6 @@ describe('query actions', () => { .then(() => { expect(store.getActions()[0]).toEqual(expectedActions[0]); }) - .catch((e : Error) => { throw e}); + .catch((e: Error) => { throw e }); }); }); diff --git a/src/tests/services/actions/query-input-action-creators.spec.tsx b/src/app/services/actions/query-input-action-creators.spec.ts similarity index 82% rename from src/tests/services/actions/query-input-action-creators.spec.tsx rename to src/app/services/actions/query-input-action-creators.spec.ts index 0f20cb7b8..de834859d 100644 --- a/src/tests/services/actions/query-input-action-creators.spec.tsx +++ b/src/app/services/actions/query-input-action-creators.spec.ts @@ -1,8 +1,8 @@ import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; -import { setSampleQuery } from '../../../app/services/actions/query-input-action-creators'; -import { SET_SAMPLE_QUERY_SUCCESS } from '../../../app/services/redux-constants'; +import { setSampleQuery } from './query-input-action-creators'; +import { SET_SAMPLE_QUERY_SUCCESS } from '../redux-constants'; const middlewares = [thunk]; const mockStore = configureMockStore(middlewares); diff --git a/src/tests/services/actions/query-status-action-creator.spec.ts b/src/app/services/actions/query-status-action-creator.spec.ts similarity index 100% rename from src/tests/services/actions/query-status-action-creator.spec.ts rename to src/app/services/actions/query-status-action-creator.spec.ts diff --git a/src/tests/services/actions/request-history-action-creators.spec.tsx b/src/app/services/actions/request-history-action-creators.spec.ts similarity index 90% rename from src/tests/services/actions/request-history-action-creators.spec.tsx rename to src/app/services/actions/request-history-action-creators.spec.ts index 090e70805..77f215a6e 100644 --- a/src/tests/services/actions/request-history-action-creators.spec.tsx +++ b/src/app/services/actions/request-history-action-creators.spec.ts @@ -1,11 +1,15 @@ import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; -import { addHistoryItem, viewHistoryItem, removeHistoryItem, - bulkRemoveHistoryItems } from '../../../app/services/actions/request-history-action-creators'; -import { ADD_HISTORY_ITEM_SUCCESS, VIEW_HISTORY_ITEM_SUCCESS, +import { + addHistoryItem, viewHistoryItem, removeHistoryItem, + bulkRemoveHistoryItems +} from './request-history-action-creators'; +import { + ADD_HISTORY_ITEM_SUCCESS, VIEW_HISTORY_ITEM_SUCCESS, REMOVE_HISTORY_ITEM_SUCCESS, - REMOVE_ALL_HISTORY_ITEMS_SUCCESS} from '../../../app/services/redux-constants'; + REMOVE_ALL_HISTORY_ITEMS_SUCCESS +} from '../redux-constants'; import { IHistoryItem } from '../../../types/history'; const middlewares = [thunk]; @@ -21,7 +25,7 @@ describe('Request History Action Creators', () => { } ]; - const store = mockStore({ history: []}); + const store = mockStore({ history: [] }); // @ts-ignore store.dispatch(addHistoryItem(historyItem)); diff --git a/src/tests/services/actions/resource-explorer-action-creators.spec.ts b/src/app/services/actions/resource-explorer-action-creators.spec.ts similarity index 100% rename from src/tests/services/actions/resource-explorer-action-creators.spec.ts rename to src/app/services/actions/resource-explorer-action-creators.spec.ts diff --git a/src/tests/services/actions/response-expanded-action-creator.spec.ts b/src/app/services/actions/response-expanded-action-creator.spec.ts similarity index 100% rename from src/tests/services/actions/response-expanded-action-creator.spec.ts rename to src/app/services/actions/response-expanded-action-creator.spec.ts diff --git a/src/tests/services/actions/samples-action-creators.spec.tsx b/src/app/services/actions/samples-action-creators.spec.ts similarity index 85% rename from src/tests/services/actions/samples-action-creators.spec.tsx rename to src/app/services/actions/samples-action-creators.spec.ts index 8625ee118..af15d2891 100644 --- a/src/tests/services/actions/samples-action-creators.spec.tsx +++ b/src/app/services/actions/samples-action-creators.spec.ts @@ -1,8 +1,10 @@ -import { fetchSamplesSuccess, fetchSamplesError, - fetchSamplesPending } from '../../../app/services/actions/samples-action-creators'; +import { + fetchSamplesSuccess, fetchSamplesError, + fetchSamplesPending +} from './samples-action-creators'; import { SAMPLES_FETCH_SUCCESS, SAMPLES_FETCH_PENDING, SAMPLES_FETCH_ERROR -} from '../../../app/services/redux-constants'; +} from '../redux-constants'; describe('actions', () => { diff --git a/src/tests/services/actions/snippets-action-creators.spec.ts b/src/app/services/actions/snippet-action-creator.spec.ts similarity index 95% rename from src/tests/services/actions/snippets-action-creators.spec.ts rename to src/app/services/actions/snippet-action-creator.spec.ts index cea26b8e3..10ba581bd 100644 --- a/src/tests/services/actions/snippets-action-creators.spec.ts +++ b/src/app/services/actions/snippet-action-creator.spec.ts @@ -5,8 +5,8 @@ import { getSnippetSuccess, getSnippetError, getSnippetPending, getSnippet -} from '../../../app/services/actions/snippet-action-creator'; -import { GET_SNIPPET_SUCCESS, GET_SNIPPET_ERROR, GET_SNIPPET_PENDING } from '../../../app/services/redux-constants'; +} from './snippet-action-creator'; +import { GET_SNIPPET_SUCCESS, GET_SNIPPET_ERROR, GET_SNIPPET_PENDING } from '../redux-constants'; const middlewares = [thunk]; const mockStore = configureMockStore(middlewares); diff --git a/src/tests/services/actions/terms-of-use-action-creator.spec.ts b/src/app/services/actions/terms-of-use-action-creator.spec.ts similarity index 100% rename from src/tests/services/actions/terms-of-use-action-creator.spec.ts rename to src/app/services/actions/terms-of-use-action-creator.spec.ts diff --git a/src/tests/services/actions/theme-action-creator.spec.ts b/src/app/services/actions/theme-action-creator.spec.ts similarity index 100% rename from src/tests/services/actions/theme-action-creator.spec.ts rename to src/app/services/actions/theme-action-creator.spec.ts diff --git a/src/tests/services/actions/toggle-sidebar-action-creators.spec.ts b/src/app/services/actions/toggle-sidebar-action-creator.spec.ts similarity index 79% rename from src/tests/services/actions/toggle-sidebar-action-creators.spec.ts rename to src/app/services/actions/toggle-sidebar-action-creator.spec.ts index 7f5c324ab..4621270f1 100644 --- a/src/tests/services/actions/toggle-sidebar-action-creators.spec.ts +++ b/src/app/services/actions/toggle-sidebar-action-creator.spec.ts @@ -1,8 +1,8 @@ import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; -import { toggleSidebar } from '../../../app/services/actions/toggle-sidebar-action-creator'; -import { TOGGLE_SIDEBAR_SUCCESS } from '../../../app/services/redux-constants'; +import { toggleSidebar } from './toggle-sidebar-action-creator'; +import { TOGGLE_SIDEBAR_SUCCESS } from '../redux-constants'; const middlewares = [thunk]; const mockStore = configureMockStore(middlewares); diff --git a/src/tests/services/reducers/adaptive-cards-reducer.spec.ts b/src/app/services/reducers/adaptive-cards-reducer.spec.ts similarity index 100% rename from src/tests/services/reducers/adaptive-cards-reducer.spec.ts rename to src/app/services/reducers/adaptive-cards-reducer.spec.ts diff --git a/src/tests/services/reducers/auth-reducers.spec.tsx b/src/app/services/reducers/auth-reducers.spec.ts similarity index 92% rename from src/tests/services/reducers/auth-reducers.spec.tsx rename to src/app/services/reducers/auth-reducers.spec.ts index 36a3652a7..353be18cc 100644 --- a/src/tests/services/reducers/auth-reducers.spec.tsx +++ b/src/app/services/reducers/auth-reducers.spec.ts @@ -1,5 +1,5 @@ -import { authToken, consentedScopes } from '../../../app/services/reducers/auth-reducers'; -import { GET_AUTH_TOKEN_SUCCESS, GET_CONSENTED_SCOPES_SUCCESS } from '../../../app/services/redux-constants'; +import { authToken, consentedScopes } from './auth-reducers'; +import { GET_AUTH_TOKEN_SUCCESS, GET_CONSENTED_SCOPES_SUCCESS } from '../redux-constants'; describe('Auth Reducer', () => { it('should return initial state', () => { diff --git a/src/tests/services/reducers/autocomplete-reducer.spec.ts b/src/app/services/reducers/autocomplete-reducer.spec.ts similarity index 100% rename from src/tests/services/reducers/autocomplete-reducer.spec.ts rename to src/app/services/reducers/autocomplete-reducer.spec.ts diff --git a/src/tests/services/reducers/graph-explorer-mode.spec.ts b/src/app/services/reducers/graph-explorer-mode.spec.ts similarity index 100% rename from src/tests/services/reducers/graph-explorer-mode.spec.ts rename to src/app/services/reducers/graph-explorer-mode.spec.ts diff --git a/src/tests/services/reducers/ocps-reducer.spec.ts b/src/app/services/reducers/ocps-reducer.spec.ts similarity index 100% rename from src/tests/services/reducers/ocps-reducer.spec.ts rename to src/app/services/reducers/ocps-reducer.spec.ts diff --git a/src/tests/services/reducers/permissions-panel-reducer.spec.ts b/src/app/services/reducers/permissions-panel-reducer.spec.ts similarity index 100% rename from src/tests/services/reducers/permissions-panel-reducer.spec.ts rename to src/app/services/reducers/permissions-panel-reducer.spec.ts diff --git a/src/tests/services/reducers/permissions-reducer.spec.ts b/src/app/services/reducers/permissions-reducer.spec.ts similarity index 100% rename from src/tests/services/reducers/permissions-reducer.spec.ts rename to src/app/services/reducers/permissions-reducer.spec.ts diff --git a/src/tests/services/reducers/profile-reducer.spec.ts b/src/app/services/reducers/profile-reducer.spec.ts similarity index 100% rename from src/tests/services/reducers/profile-reducer.spec.ts rename to src/app/services/reducers/profile-reducer.spec.ts diff --git a/src/tests/services/reducers/query-input-reducers.spec.tsx b/src/app/services/reducers/query-input-reducers.spec.ts similarity index 82% rename from src/tests/services/reducers/query-input-reducers.spec.tsx rename to src/app/services/reducers/query-input-reducers.spec.ts index 9f9889317..ee6a9172f 100644 --- a/src/tests/services/reducers/query-input-reducers.spec.tsx +++ b/src/app/services/reducers/query-input-reducers.spec.ts @@ -1,5 +1,5 @@ -import { sampleQuery } from '../../../app/services/reducers/query-input-reducers'; -import { SET_SAMPLE_QUERY_SUCCESS } from '../../../app/services/redux-constants'; +import { sampleQuery } from './query-input-reducers'; +import { SET_SAMPLE_QUERY_SUCCESS } from '../redux-constants'; describe('Query INput Reducer', () => { it('should return initial state', () => { diff --git a/src/tests/services/reducers/query-loading-reducer.spec.ts b/src/app/services/reducers/query-loading-reducers.spec.ts similarity index 94% rename from src/tests/services/reducers/query-loading-reducer.spec.ts rename to src/app/services/reducers/query-loading-reducers.spec.ts index ac62da207..f82a9eab2 100644 --- a/src/tests/services/reducers/query-loading-reducer.spec.ts +++ b/src/app/services/reducers/query-loading-reducers.spec.ts @@ -1,4 +1,4 @@ -import { isLoadingData } from '../../../app/services/reducers/query-loading-reducers'; +import { isLoadingData } from './query-loading-reducers'; import { FETCH_SCOPES_ERROR, GET_CONSENT_ERROR, @@ -7,7 +7,7 @@ import { QUERY_GRAPH_RUNNING, QUERY_GRAPH_STATUS, QUERY_GRAPH_SUCCESS -} from '../../../app/services/redux-constants'; +} from '../redux-constants'; describe('Query loading reducer', () => { it('should return false in case of get_consent error', () => { diff --git a/src/tests/services/reducers/query-runner-reducers.spec.tsx b/src/app/services/reducers/query-runner-reducers.spec.ts similarity index 84% rename from src/tests/services/reducers/query-runner-reducers.spec.tsx rename to src/app/services/reducers/query-runner-reducers.spec.ts index 8fa3f8d18..a502ba32d 100644 --- a/src/tests/services/reducers/query-runner-reducers.spec.tsx +++ b/src/app/services/reducers/query-runner-reducers.spec.ts @@ -1,7 +1,9 @@ -import { graphResponse } from '../../../app/services/reducers/query-runner-reducers'; -import { queryRunnerStatus } from '../../../app/services/reducers/query-runner-status-reducers'; -import { CLEAR_QUERY_STATUS, QUERY_GRAPH_RUNNING, QUERY_GRAPH_STATUS, - QUERY_GRAPH_SUCCESS, VIEW_HISTORY_ITEM_SUCCESS } from '../../../app/services/redux-constants'; +import { graphResponse } from './query-runner-reducers'; +import { queryRunnerStatus } from './query-runner-status-reducers'; +import { + CLEAR_QUERY_STATUS, QUERY_GRAPH_RUNNING, QUERY_GRAPH_STATUS, + QUERY_GRAPH_SUCCESS, VIEW_HISTORY_ITEM_SUCCESS +} from '../redux-constants'; import { IGraphResponse } from '../../../types/query-response'; describe('Query Runner Reducer', () => { @@ -60,7 +62,7 @@ describe('Query Runner Reducer', () => { } }; - const action = { type: VIEW_HISTORY_ITEM_SUCCESS, response: mockResponse }; + const action = { type: VIEW_HISTORY_ITEM_SUCCESS, response: mockResponse }; const newState = queryRunnerStatus(initialState, action); expect(newState).toEqual(null); diff --git a/src/tests/services/reducers/request-history-reducers.spec.tsx b/src/app/services/reducers/request-history-reducers.spec.ts similarity index 86% rename from src/tests/services/reducers/request-history-reducers.spec.tsx rename to src/app/services/reducers/request-history-reducers.spec.ts index 6dc589bee..7fd606c41 100644 --- a/src/tests/services/reducers/request-history-reducers.spec.tsx +++ b/src/app/services/reducers/request-history-reducers.spec.ts @@ -1,6 +1,8 @@ -import { history } from '../../../app/services/reducers/request-history-reducers'; -import { ADD_HISTORY_ITEM_SUCCESS, REMOVE_ALL_HISTORY_ITEMS_SUCCESS, - REMOVE_HISTORY_ITEM_SUCCESS } from '../../../app/services/redux-constants'; +import { history } from './request-history-reducers'; +import { + ADD_HISTORY_ITEM_SUCCESS, REMOVE_ALL_HISTORY_ITEMS_SUCCESS, + REMOVE_HISTORY_ITEM_SUCCESS +} from '../redux-constants'; describe('Request History Reducer', () => { diff --git a/src/tests/services/reducers/resources-reducer.spec.ts b/src/app/services/reducers/resources-reducer.spec.ts similarity index 100% rename from src/tests/services/reducers/resources-reducer.spec.ts rename to src/app/services/reducers/resources-reducer.spec.ts diff --git a/src/tests/services/reducers/samples-reducers.spec.tsx b/src/app/services/reducers/samples-reducers.spec.tsx similarity index 100% rename from src/tests/services/reducers/samples-reducers.spec.tsx rename to src/app/services/reducers/samples-reducers.spec.tsx diff --git a/src/tests/services/reducers/snippets-reducer.spec.ts b/src/app/services/reducers/snippet-reducer.spec.ts similarity index 85% rename from src/tests/services/reducers/snippets-reducer.spec.ts rename to src/app/services/reducers/snippet-reducer.spec.ts index 5a0ce5241..112a94c93 100644 --- a/src/tests/services/reducers/snippets-reducer.spec.ts +++ b/src/app/services/reducers/snippet-reducer.spec.ts @@ -1,5 +1,5 @@ -import { snippets } from '../../../app/services/reducers/snippet-reducer'; -import { GET_SNIPPET_ERROR, GET_SNIPPET_SUCCESS } from '../../../app/services/redux-constants'; +import { snippets } from './snippet-reducer'; +import { GET_SNIPPET_ERROR, GET_SNIPPET_SUCCESS } from '../redux-constants'; describe('Graph Explorer Snippet Reducer', () => { it('should set csharp code snippet', () => { diff --git a/src/tests/services/reducers/terms-of-use-reducer.spec.ts b/src/app/services/reducers/terms-of-use-reducer.spec.ts similarity index 100% rename from src/tests/services/reducers/terms-of-use-reducer.spec.ts rename to src/app/services/reducers/terms-of-use-reducer.spec.ts diff --git a/src/tests/services/reducers/togle-sidebar-reducer.spec.ts b/src/app/services/reducers/toggle-sidebar-reducer.spec.ts similarity index 94% rename from src/tests/services/reducers/togle-sidebar-reducer.spec.ts rename to src/app/services/reducers/toggle-sidebar-reducer.spec.ts index 082269105..6a376ec97 100644 --- a/src/tests/services/reducers/togle-sidebar-reducer.spec.ts +++ b/src/app/services/reducers/toggle-sidebar-reducer.spec.ts @@ -1,8 +1,8 @@ -import { sidebarProperties } from '../../../app/services/reducers/toggle-sidebar-reducer'; +import { sidebarProperties } from './toggle-sidebar-reducer'; import { SET_SAMPLE_QUERY_SUCCESS, TOGGLE_SIDEBAR_SUCCESS, VIEW_HISTORY_ITEM_SUCCESS -} from '../../../app/services/redux-constants'; +} from '../redux-constants'; describe('Toggle sidebar', () => { diff --git a/src/tests/utils/dynamic-sort.spec.tsx b/src/app/utils/dynamic-sort.spec.ts similarity index 96% rename from src/tests/utils/dynamic-sort.spec.tsx rename to src/app/utils/dynamic-sort.spec.ts index 68a2cfbb4..9dff155b7 100644 --- a/src/tests/utils/dynamic-sort.spec.tsx +++ b/src/app/utils/dynamic-sort.spec.ts @@ -1,4 +1,4 @@ -import { dynamicSort } from '../../app/utils/dynamic-sort'; +import { dynamicSort } from './dynamic-sort'; import { SortOrder } from '../../types/enums'; describe('Dynamic Sort', () => { diff --git a/src/tests/utils/external-link-validation.spec.ts b/src/app/utils/external-link-validation.spec.ts similarity index 92% rename from src/tests/utils/external-link-validation.spec.ts rename to src/app/utils/external-link-validation.spec.ts index 65a1d39a6..f7c4f2be7 100644 --- a/src/tests/utils/external-link-validation.spec.ts +++ b/src/app/utils/external-link-validation.spec.ts @@ -1,4 +1,5 @@ -import { isValidHttpsUrl, validateExternalLink } from '../../app/utils/external-link-validation'; +import { isValidHttpsUrl, validateExternalLink } from './external-link-validation'; + describe('External link', () => { const links = [ diff --git a/src/tests/utils/generate-groups.spec.ts b/src/app/utils/generate-groups.spec.ts similarity index 97% rename from src/tests/utils/generate-groups.spec.ts rename to src/app/utils/generate-groups.spec.ts index de6bdd6c5..c572d88b8 100644 --- a/src/tests/utils/generate-groups.spec.ts +++ b/src/app/utils/generate-groups.spec.ts @@ -1,4 +1,4 @@ -import { generateGroupsFromList } from '../../app/utils/generate-groups'; +import { generateGroupsFromList } from './generate-groups'; function setUp() { return [{ diff --git a/src/tests/utils/get-messages.ts b/src/app/utils/get-messages.ts similarity index 100% rename from src/tests/utils/get-messages.ts rename to src/app/utils/get-messages.ts diff --git a/src/tests/utils/graph-toolkit-lookup.spec.ts b/src/app/utils/graph-toolkit-lookup.spec.ts similarity index 92% rename from src/tests/utils/graph-toolkit-lookup.spec.ts rename to src/app/utils/graph-toolkit-lookup.spec.ts index 116ce2758..9022d8ecc 100644 --- a/src/tests/utils/graph-toolkit-lookup.spec.ts +++ b/src/app/utils/graph-toolkit-lookup.spec.ts @@ -1,4 +1,4 @@ -import { lookupToolkitUrl } from '../../app/utils/graph-toolkit-lookup'; +import { lookupToolkitUrl } from './graph-toolkit-lookup'; describe('Tests lookToolkitUrl', () => { it('Returns valid toolkit url depending on sampleQuery passed', () => { diff --git a/src/tests/utils/hash-string.spec.ts b/src/app/utils/hash-string.spec.ts similarity index 86% rename from src/tests/utils/hash-string.spec.ts rename to src/app/utils/hash-string.spec.ts index 8c2451e6f..1b1a1ac8d 100644 --- a/src/tests/utils/hash-string.spec.ts +++ b/src/app/utils/hash-string.spec.ts @@ -1,4 +1,4 @@ -import { stringToHash } from '../../app/utils/hash-string'; +import { stringToHash } from './hash-string'; describe('String to hash should', () => { diff --git a/src/tests/utils/open-api-parser.spec.ts b/src/app/utils/open-api-parser.spec.ts similarity index 79% rename from src/tests/utils/open-api-parser.spec.ts rename to src/app/utils/open-api-parser.spec.ts index 796f39728..73236aa36 100644 --- a/src/tests/utils/open-api-parser.spec.ts +++ b/src/app/utils/open-api-parser.spec.ts @@ -1,7 +1,6 @@ -import { parseOpenApiResponse } from '../../app/utils/open-api-parser'; -import { parseSampleUrl } from '../../app/utils/sample-url-generation'; +import { parseOpenApiResponse } from './open-api-parser'; import { getSample } from './open-api-sample'; - +import { parseSampleUrl } from './sample-url-generation'; describe('Open api spec parser should', () => { diff --git a/src/tests/utils/open-api-sample.ts b/src/app/utils/open-api-sample.ts similarity index 100% rename from src/tests/utils/open-api-sample.ts rename to src/app/utils/open-api-sample.ts diff --git a/src/tests/utils/sanitize-query-parameter-sanitization.spec.tsx b/src/app/utils/query-parameter-sanitization.spec.ts similarity index 94% rename from src/tests/utils/sanitize-query-parameter-sanitization.spec.tsx rename to src/app/utils/query-parameter-sanitization.spec.ts index f07ae8648..92c9e82d8 100644 --- a/src/tests/utils/sanitize-query-parameter-sanitization.spec.tsx +++ b/src/app/utils/query-parameter-sanitization.spec.ts @@ -1,6 +1,20 @@ -import { - sanitizeQueryParameter -} from '../../app/utils/query-parameter-sanitization'; +import { isAllAlpha, sanitizeQueryParameter } from './query-parameter-sanitization'; + +describe('isAllAlpha should ', () => { + const list = [ + { key: 'aaa', isAllAlphabetic: true }, + { key: 'aZa', isAllAlphabetic: true }, + { key: '111', isAllAlphabetic: false }, + { key: '1a1', isAllAlphabetic: false } + ]; + + list.forEach(element => { + it(`return ${element.isAllAlphabetic} for ${element.key}`, () => { + const key = isAllAlpha(element.key); + expect(key).toBe(element.isAllAlphabetic); + }); + }); +}); describe('Sanitize Query Parameters should', () => { const list = [ diff --git a/src/tests/utils/sanitize-url-sanitization.spec.tsx b/src/app/utils/query-url-sanitization.spec.ts similarity index 89% rename from src/tests/utils/sanitize-url-sanitization.spec.tsx rename to src/app/utils/query-url-sanitization.spec.ts index fe99ea98f..5fd28b698 100644 --- a/src/tests/utils/sanitize-url-sanitization.spec.tsx +++ b/src/app/utils/query-url-sanitization.spec.ts @@ -1,26 +1,6 @@ -import { - isAllAlpha -} from '../../app/utils/query-parameter-sanitization'; import { isDeprecation, sanitizeQueryUrl -} from '../../app/utils/query-url-sanitization'; - - -describe('isAllAlpha should ', () => { - const list = [ - { key: 'aaa', isAllAlphabetic: true }, - { key: 'aZa', isAllAlphabetic: true }, - { key: '111', isAllAlphabetic: false }, - { key: '1a1', isAllAlphabetic: false } - ]; - - list.forEach(element => { - it(`return ${element.isAllAlphabetic} for ${element.key}`, () => { - const key = isAllAlpha(element.key); - expect(key).toBe(element.isAllAlphabetic); - }); - }); -}); +} from './query-url-sanitization'; describe('isDepraction should ', () => { const list = [ diff --git a/src/tests/utils/sample-url-generation.spec.tsx b/src/app/utils/sample-url-generation.spec.ts similarity index 76% rename from src/tests/utils/sample-url-generation.spec.tsx rename to src/app/utils/sample-url-generation.spec.ts index 9773c2938..bc0eac68f 100644 --- a/src/tests/utils/sample-url-generation.spec.tsx +++ b/src/app/utils/sample-url-generation.spec.ts @@ -1,4 +1,4 @@ -import { hasWhiteSpace, parseSampleUrl } from '../../app/utils/sample-url-generation'; +import { hasWhiteSpace, parseSampleUrl } from './sample-url-generation'; describe('Sample Url Generation', () => { @@ -80,15 +80,17 @@ describe('Sample Url Generation', () => { describe('hasWhiteSpaces should', () => { const invalidUrls = [ - {url: ' https://graph.microsoft.com/v1.0/me', output: false}, - {url: 'https: //graph.microsoft.com/v1.0/me', output: true}, - {url: 'https://%20graph.microsoft.com/v1.0/me', output: true}, - {url: 'https://graph.microsoft.com/ v1.0/me', output: true}, - {url: 'https://graph.microsoft.com/v1.0/ me', output: true}, - {url: - 'https://graph.microsoft.com/v1.0/me/contacts?$filter=emailAddresses/any(a:a/address eq \'garth@contoso.com\')', - output: false}, - {url: 'https://graph.microsoft.com/v1.0/me ', output: false} + { url: ' https://graph.microsoft.com/v1.0/me', output: false }, + { url: 'https: //graph.microsoft.com/v1.0/me', output: true }, + { url: 'https://%20graph.microsoft.com/v1.0/me', output: true }, + { url: 'https://graph.microsoft.com/ v1.0/me', output: true }, + { url: 'https://graph.microsoft.com/v1.0/ me', output: true }, + { + url: + 'https://graph.microsoft.com/v1.0/me/contacts?$filter=emailAddresses/any(a:a/address eq \'garth@contoso.com\')', + output: false + }, + { url: 'https://graph.microsoft.com/v1.0/me ', output: false } ]; invalidUrls.forEach(invalidUrl => { it(`validate whitespaces in the url: ${invalidUrl.url}`, () => { diff --git a/src/tests/utils/url-to-html.spec.ts b/src/app/utils/status-message.spec.ts similarity index 97% rename from src/tests/utils/url-to-html.spec.ts rename to src/app/utils/status-message.spec.ts index b889589df..5e2188b77 100644 --- a/src/tests/utils/url-to-html.spec.ts +++ b/src/app/utils/status-message.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable max-len */ -import { extractUrl, replaceLinks, convertArrayToObject, getMatchesAndParts, setStatusMessage } from '../../app/utils/status-message'; +import { extractUrl, replaceLinks, convertArrayToObject, getMatchesAndParts, setStatusMessage } from './status-message'; describe('status message should', () => { diff --git a/src/tests/utils/token-helpers.spec.ts b/src/app/utils/token-helpers.spec.ts similarity index 100% rename from src/tests/utils/token-helpers.spec.ts rename to src/app/utils/token-helpers.spec.ts diff --git a/src/tests/common/copy.spec.ts b/src/app/views/common/copy.spec.ts similarity index 75% rename from src/tests/common/copy.spec.ts rename to src/app/views/common/copy.spec.ts index 4daac2b6f..8cf3d5405 100644 --- a/src/tests/common/copy.spec.ts +++ b/src/app/views/common/copy.spec.ts @@ -1,10 +1,10 @@ -import { genericCopy } from '../../app/views/common/copy'; +import { genericCopy } from './copy'; describe('Tests copy.ts', () => { it('Tests generic copy which resolves to an empty object ', () => { document.execCommand = jest.fn(); genericCopy('dummy text') - .then((response) => { + .then((response: any) => { expect(response).toBe('copied'); }) .catch((e: Error) => { throw e }) diff --git a/src/tests/common/download.spec.ts b/src/app/views/common/download.spec.ts similarity index 80% rename from src/tests/common/download.spec.ts rename to src/app/views/common/download.spec.ts index c840910f7..d31c3ce67 100644 --- a/src/tests/common/download.spec.ts +++ b/src/app/views/common/download.spec.ts @@ -1,4 +1,4 @@ -import { downloadToLocal } from '../../app/views/common/download'; +import { downloadToLocal } from './download'; window.URL.createObjectURL = jest.fn(); diff --git a/src/tests/common/monaco-tests/format-json.spec.ts b/src/app/views/common/monaco/util/format-json.spec.ts similarity index 81% rename from src/tests/common/monaco-tests/format-json.spec.ts rename to src/app/views/common/monaco/util/format-json.spec.ts index f0508b14b..26a1951d9 100644 --- a/src/tests/common/monaco-tests/format-json.spec.ts +++ b/src/app/views/common/monaco/util/format-json.spec.ts @@ -1,5 +1,5 @@ -import { formatJsonStringForAllBrowsers } from '../../../app/views/common/monaco/util/format-json'; -import { formatXml } from '../../../app/views/common/monaco/util/format-xml'; +import { formatJsonStringForAllBrowsers } from './format-json'; +import { formatXml } from './format-xml'; describe('Tests json strings formatting in monaco editor ', () => { it('Tests json strings formatting in monaco editor', () => { diff --git a/src/app/views/query-response/QueryResponse.spec.tsx b/src/app/views/query-response/QueryResponse.spec.tsx index 9fd7e6a04..4ab138706 100644 --- a/src/app/views/query-response/QueryResponse.spec.tsx +++ b/src/app/views/query-response/QueryResponse.spec.tsx @@ -6,7 +6,7 @@ import { Mode } from '../../../types/enums'; import { IntlProvider } from 'react-intl'; import { geLocale } from '../../../appLocale'; import messages from '../../../messages'; -import { messages_ } from '../../../tests/utils/get-messages'; +import { messages_ } from '../../utils/get-messages'; afterEach(cleanup); const renderQueryResponse = () => { diff --git a/src/app/views/query-runner/query-input/QueryInput.spec.tsx b/src/app/views/query-runner/query-input/QueryInput.spec.tsx index c20a24e40..2176834e7 100644 --- a/src/app/views/query-runner/query-input/QueryInput.spec.tsx +++ b/src/app/views/query-runner/query-input/QueryInput.spec.tsx @@ -4,10 +4,10 @@ import { IntlProvider } from 'react-intl'; import { geLocale } from '../../../../appLocale'; import messages from '../../../../messages'; -import { messages_ } from '../../../../tests/utils/get-messages'; import { Mode } from '../../../../types/enums'; import { IQueryInputProps } from '../../../../types/query-runner'; import IntlQueryInput from './QueryInput'; +import { messages_ } from '../../../utils/get-messages'; afterEach(cleanup); const renderQueryInput = (args?: any): any => { diff --git a/src/app/views/query-runner/query-input/auto-complete/auto-complete.styles.ts b/src/app/views/query-runner/query-input/auto-complete/AutoComplete.styles.ts similarity index 100% rename from src/app/views/query-runner/query-input/auto-complete/auto-complete.styles.ts rename to src/app/views/query-runner/query-input/auto-complete/AutoComplete.styles.ts diff --git a/src/app/views/query-runner/query-input/auto-complete/AutoComplete.tsx b/src/app/views/query-runner/query-input/auto-complete/AutoComplete.tsx index 548d4283c..1b24475a7 100644 --- a/src/app/views/query-runner/query-input/auto-complete/AutoComplete.tsx +++ b/src/app/views/query-runner/query-input/auto-complete/AutoComplete.tsx @@ -260,7 +260,7 @@ class AutoComplete extends Component { }); } - private sortSuggestions(suggestions: string[]): string[]{ + private sortSuggestions(suggestions: string[]): string[] { return suggestions.sort(dynamicSort(null, SortOrder.ASC)); } diff --git a/src/tests/utils/auto-complete.util.spec.ts b/src/app/views/query-runner/query-input/auto-complete/auto-complete.util.spec.ts similarity index 64% rename from src/tests/utils/auto-complete.util.spec.ts rename to src/app/views/query-runner/query-input/auto-complete/auto-complete.util.spec.ts index 9ffc9aeae..493e47398 100644 --- a/src/tests/utils/auto-complete.util.spec.ts +++ b/src/app/views/query-runner/query-input/auto-complete/auto-complete.util.spec.ts @@ -1,8 +1,9 @@ +import { IAutoCompleteProps } from '../../../../../types/auto-complete'; import { - cleanUpSelectedSuggestion, getParametersWithVerb, getLastCharacterOf, getLastSymbolInUrl, - getFilteredSuggestions -} from '../../app/views/query-runner/query-input/auto-complete/auto-complete.util'; -import { IAutoCompleteProps } from '../../types/auto-complete'; + cleanUpSelectedSuggestion, + getParametersWithVerb, getLastCharacterOf, + getFilteredSuggestions, getLastSymbolInUrl +} from './auto-complete.util'; describe('Tests autocomplete utils', () => { it('Tests cleanUpSelectedSuggestion', () => { @@ -77,4 +78,27 @@ describe('Tests autocomplete utils', () => { const result = getLastSymbolInUrl(url); expect(result).toEqual({ key: '/', value: 32 }); }) -}) \ No newline at end of file +}) + +describe('Query input util should', () => { + + it('cleanup selected suggestion', async () => { + const compareString = 'sel'; + const userInput = 'https://graph.microsoft.com/v1.0/me/messages?sel'; + const selected = '$select'; + const selectedSuggestion = cleanUpSelectedSuggestion(compareString, userInput, selected); + + expect(selectedSuggestion).toEqual('https://graph.microsoft.com/v1.0/me/messages?$select'); + }); + + it('replace only last occurrence of compare string', async () => { + const compareString = 'su'; + const userInput = 'https://graph.microsoft.com/v1.0/me/messages?$select=id,subject&orderby=su'; + const selected = 'subject desc'; + const selectedSuggestion = cleanUpSelectedSuggestion(compareString, userInput, selected); + + expect(selectedSuggestion) + .toEqual('https://graph.microsoft.com/v1.0/me/messages?$select=id,subject&orderby=subject desc'); + }); + +}); \ No newline at end of file diff --git a/src/app/views/query-runner/query-input/auto-complete/suggestion-list/SuggestionsList.tsx b/src/app/views/query-runner/query-input/auto-complete/suggestion-list/SuggestionsList.tsx index f0df7c2fe..866703e2f 100644 --- a/src/app/views/query-runner/query-input/auto-complete/suggestion-list/SuggestionsList.tsx +++ b/src/app/views/query-runner/query-input/auto-complete/suggestion-list/SuggestionsList.tsx @@ -3,7 +3,7 @@ import React, { useEffect } from 'react'; import { ISuggestionsList } from '../../../../../../types/auto-complete'; import { classNames } from '../../../../classnames'; -import { autoCompleteStyles } from '../auto-complete.styles'; +import { autoCompleteStyles } from '../AutoComplete.styles'; const styledSuggesions = (props: any) => { const { filteredSuggestions, activeSuggestion, onClick }: ISuggestionsList = props; diff --git a/src/app/views/query-runner/request/Request.spec.tsx b/src/app/views/query-runner/request/Request.spec.tsx index d79d8b179..ff285d3d3 100644 --- a/src/app/views/query-runner/request/Request.spec.tsx +++ b/src/app/views/query-runner/request/Request.spec.tsx @@ -4,9 +4,9 @@ import { IntlProvider } from 'react-intl'; import { Request } from '../../../../app/views/query-runner/request/Request'; import { geLocale } from '../../../../appLocale'; -import { messages_ } from '../../../../tests/utils/get-messages'; import { Mode } from '../../../../types/enums'; import { IRequestComponent } from '../../../../types/request'; +import { messages_ } from '../../../utils/get-messages'; afterEach(cleanup); const renderRequest = (): any => { diff --git a/src/app/views/settings/Settings.spec.tsx b/src/app/views/settings/Settings.spec.tsx index 8dedeb25d..61d0ed34a 100644 --- a/src/app/views/settings/Settings.spec.tsx +++ b/src/app/views/settings/Settings.spec.tsx @@ -5,8 +5,8 @@ import userEvent from '@testing-library/user-event'; import { Settings } from '.'; import { geLocale } from '../../../appLocale'; -import { messages_ } from '../../../tests/utils/get-messages'; import { ISettingsProps } from '../../../types/settings'; +import { messages_ } from '../../utils/get-messages'; afterEach(cleanup); const renderSettings = (args?: any) => { diff --git a/src/app/views/sidebar/history/History.spec.tsx b/src/app/views/sidebar/history/History.spec.tsx index 831c80d2c..8109e398f 100644 --- a/src/app/views/sidebar/history/History.spec.tsx +++ b/src/app/views/sidebar/history/History.spec.tsx @@ -3,9 +3,9 @@ import { cleanup, render, screen } from '@testing-library/react'; import { IntlProvider } from 'react-intl'; import { geLocale } from '../../../../appLocale'; -import { messages_ } from '../../../../tests/utils/get-messages'; import { IHistoryProps } from '../../../../types/history'; import { History } from './History'; +import { messages_ } from '../../../utils/get-messages'; interface IExtendedHistory extends IHistoryProps { intl: object; diff --git a/src/tests/utils/postman-util.spec.ts b/src/app/views/sidebar/resource-explorer/panels/postman.util.spec.ts similarity index 59% rename from src/tests/utils/postman-util.spec.ts rename to src/app/views/sidebar/resource-explorer/panels/postman.util.spec.ts index 4249e6f91..c214a37a7 100644 --- a/src/tests/utils/postman-util.spec.ts +++ b/src/app/views/sidebar/resource-explorer/panels/postman.util.spec.ts @@ -1,10 +1,8 @@ -import content from '../../app/utils/resources/resources.json'; -import { generatePostmanCollection } from '../../app/views/sidebar/resource-explorer/panels/postman.util'; -import { - createResourcesList, - getResourcePaths -} from '../../app/views/sidebar/resource-explorer/resource-explorer.utils'; -import { IResource } from '../../types/resources'; +import { IResource } from '../../../../../types/resources'; +import content from '../../../../utils/resources/resources.json'; +import { createResourcesList, getResourcePaths } from '../resource-explorer.utils'; +import { generatePostmanCollection } from './postman.util'; + const resource = JSON.parse(JSON.stringify(content)) as IResource; describe('Postman collection should', () => { diff --git a/src/tests/utils/resource-payload-filter.spec.ts b/src/app/views/sidebar/resource-explorer/resource-explorer.utils.spec.ts similarity index 86% rename from src/tests/utils/resource-payload-filter.spec.ts rename to src/app/views/sidebar/resource-explorer/resource-explorer.utils.spec.ts index d889cf343..2ec512241 100644 --- a/src/tests/utils/resource-payload-filter.spec.ts +++ b/src/app/views/sidebar/resource-explorer/resource-explorer.utils.spec.ts @@ -1,14 +1,11 @@ -import content from '../../app/utils/resources/resources.json'; +import { IResource } from '../../../../types/resources'; +import content from '../../../utils/resources/resources.json'; import { - createResourcesList, - getAvailableMethods, - getCurrentTree, - getResourcePaths, - getResourcesSupportedByVersion, - getUrlFromLink, - removeCounter -} from '../../app/views/sidebar/resource-explorer/resource-explorer.utils'; -import { IResource } from '../../types/resources'; + getResourcesSupportedByVersion, createResourcesList, + getCurrentTree, getAvailableMethods, removeCounter, + getUrlFromLink, getResourcePaths +} from './resource-explorer.utils'; + const resource = JSON.parse(JSON.stringify(content)) as IResource; describe('Resource payload should', () => { diff --git a/src/app/views/sidebar/sample-queries/SampleQueries.spec.tsx b/src/app/views/sidebar/sample-queries/SampleQueries.spec.tsx index cf0f104cf..4db44a313 100644 --- a/src/app/views/sidebar/sample-queries/SampleQueries.spec.tsx +++ b/src/app/views/sidebar/sample-queries/SampleQueries.spec.tsx @@ -4,9 +4,9 @@ import userEvent from '@testing-library/user-event' import { IntlProvider } from 'react-intl'; import { geLocale } from '../../../../appLocale'; -import { messages_ } from '../../../../tests/utils/get-messages'; import { ISampleQueriesProps } from '../../../../types/query-runner'; import SampleQueries from './SampleQueries'; +import { messages_ } from '../../../utils/get-messages'; afterEach(cleanup); const renderSampleQueries = () => { diff --git a/src/tests/authentication/AuthenticationWrapper.spec.ts b/src/modules/authentication/AuthenticationWrapper.spec.ts similarity index 94% rename from src/tests/authentication/AuthenticationWrapper.spec.ts rename to src/modules/authentication/AuthenticationWrapper.spec.ts index b59d62394..2c0b36580 100644 --- a/src/tests/authentication/AuthenticationWrapper.spec.ts +++ b/src/modules/authentication/AuthenticationWrapper.spec.ts @@ -1,5 +1,5 @@ -import { AuthenticationWrapper } from '../../../src/modules/authentication/AuthenticationWrapper'; import { HOME_ACCOUNT_KEY } from '../../app/services/graph-constants'; +import { AuthenticationWrapper } from './AuthenticationWrapper'; window.open = jest.fn(); jest.spyOn(window.sessionStorage.__proto__, 'clear'); @@ -8,7 +8,7 @@ jest.spyOn(window.localStorage.__proto__, 'setItem'); jest.spyOn(window.localStorage.__proto__, 'getItem'); jest.spyOn(window.localStorage.__proto__, 'removeItem'); -jest.mock('../../modules/authentication/msal-app.ts', () => { +jest.mock('./msal-app.ts', () => { const msalApplication = { account: null, getAccount: jest.fn(), diff --git a/src/tests/authentication/authUtils.spec.ts b/src/modules/authentication/authUtils.spec.ts similarity index 75% rename from src/tests/authentication/authUtils.spec.ts rename to src/modules/authentication/authUtils.spec.ts index f3859e917..d3fe0bd5f 100644 --- a/src/tests/authentication/authUtils.spec.ts +++ b/src/modules/authentication/authUtils.spec.ts @@ -1,5 +1,5 @@ -import { getLoginType, getCurrentUri } from '../../../src/modules/authentication/authUtils'; import { LoginType } from '../../types/enums'; +import { getLoginType, getCurrentUri } from './authUtils'; describe('Tests auth utils', () => { it('Returns valid login type', () => { diff --git a/src/tests/utils/proxy-url.spec.ts b/src/tests/proxy-url.spec.ts similarity index 74% rename from src/tests/utils/proxy-url.spec.ts rename to src/tests/proxy-url.spec.ts index 080c30ff6..b8817ab0f 100644 --- a/src/tests/utils/proxy-url.spec.ts +++ b/src/tests/proxy-url.spec.ts @@ -1,9 +1,10 @@ -import { GRAPH_API_SANDBOX_ENDPOINT_URL } from '../../app/services/graph-constants'; import fetch from 'isomorphic-fetch'; -import { isValidHttpsUrl } from '../../app/utils/external-link-validation'; -import { createAnonymousRequest } from '../../app/services/actions/query-action-creator-util'; -import { IQuery } from '../../types/query-runner'; -import { IStatus } from '../../types/status'; + +import { createAnonymousRequest } from '../app/services/actions/query-action-creator-util'; +import { GRAPH_API_SANDBOX_ENDPOINT_URL } from '../app/services/graph-constants'; +import { isValidHttpsUrl } from '../app/utils/external-link-validation'; +import { IQuery } from '../types/query-runner'; +import { IStatus } from '../types/status'; describe('Sandbox api fetch should', () => { diff --git a/src/tests/services/reducers/toggle-sidebar.spec.tsx b/src/tests/services/reducers/toggle-sidebar.spec.tsx deleted file mode 100644 index 358b4c47e..000000000 --- a/src/tests/services/reducers/toggle-sidebar.spec.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { sidebarProperties } from '../../../app/services/reducers/toggle-sidebar-reducer'; -import { TOGGLE_SIDEBAR_SUCCESS } from '../../../app/services/redux-constants'; - -describe('Toggle Sidebar Reducer', () => { - it('should toggle the sidebar', () => { - const initialState = { - mobileScreen: false, - showSidebar: false - }; - - const properties = { - mobileScreen: true, - showSidebar: true - }; - - const dummyAction = { - type: TOGGLE_SIDEBAR_SUCCESS, response: properties - }; - - const newState = sidebarProperties(initialState, dummyAction); - - expect(newState).toEqual(properties); - - }); -}); diff --git a/src/tests/utils/query-input-util.spec.ts b/src/tests/utils/query-input-util.spec.ts deleted file mode 100644 index ee8b1da69..000000000 --- a/src/tests/utils/query-input-util.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { cleanUpSelectedSuggestion } from '../../app/views/query-runner/query-input/auto-complete/auto-complete.util'; - - -describe('Query input util should', () => { - - it('cleanup selected suggestion', async () => { - const compareString = 'sel'; - const userInput = 'https://graph.microsoft.com/v1.0/me/messages?sel'; - const selected = '$select'; - const selectedSuggestion = cleanUpSelectedSuggestion(compareString, userInput, selected); - - expect(selectedSuggestion).toEqual('https://graph.microsoft.com/v1.0/me/messages?$select'); - }); - - it('replace only last occurrence of compare string', async () => { - const compareString = 'su'; - const userInput = 'https://graph.microsoft.com/v1.0/me/messages?$select=id,subject&orderby=su'; - const selected = 'subject desc'; - const selectedSuggestion = cleanUpSelectedSuggestion(compareString, userInput, selected); - - expect(selectedSuggestion) - .toEqual('https://graph.microsoft.com/v1.0/me/messages?$select=id,subject&orderby=subject desc'); - }); - -}); - - diff --git a/src/tests/utils/sanitize-url.spec.tsx b/src/tests/utils/sanitize-url.spec.tsx deleted file mode 100644 index 0e4d9720b..000000000 --- a/src/tests/utils/sanitize-url.spec.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import { isAllAlpha } from '../../app/utils/query-parameter-sanitization'; -import { - isDeprecation, - sanitizeQueryUrl -} from '../../app/utils/query-url-sanitization'; - -describe('isAllAlpha should ', () => { - const list = [ - { key: 'aaa', isAllAlphabetic: true }, - { key: 'aZa', isAllAlphabetic: true }, - { key: '111', isAllAlphabetic: false }, - { key: '1a1', isAllAlphabetic: false } - ]; - - list.forEach((element) => { - it(`return ${element.isAllAlphabetic} for ${element.key}`, () => { - const key = isAllAlpha(element.key); - expect(key).toBe(element.isAllAlphabetic); - }); - }); -}); - -describe('isDepraction should ', () => { - const list = [ - { key: 'messages_V2', depracated: true }, - { key: 'messages', depracated: false }, - { key: 'users_v2', depracated: true }, - { key: 'users', depracated: false } - ]; - - list.forEach((element) => { - it(`return ${element.depracated} for ${element.key}`, () => { - const key = isDeprecation(element.key); - expect(key).toBe(element.depracated); - }); - }); -}); - -describe('Sanitize Query Url should', () => { - const list = [ - { - check: 'without task id', - url: - 'https://graph.microsoft.com/v1.0/planner/tasks/oIx3zN98jEmVOM-4mUJzSGUANeje', - sanitized: 'https://graph.microsoft.com/v1.0/planner/tasks/{tasks-id}' - }, - { - check: 'without email', - url: - 'https://graph.microsoft.com/v1.0/users/MiriamG@M365x214355.onmicrosoft.com', - sanitized: 'https://graph.microsoft.com/v1.0/users/{users-id}' - }, - { - check: 'without message id', - // eslint-disable-next-line max-len - url: 'https://graph.microsoft.com/v1.0/me/messages/AAMkAGVmMDEzMTM4LTZmYWUtNDdkNC1hMDZiLTU1OGY5OTZhYmY4OABGAAAAAAAiQ8W967B7TKBjgx9rVEURBwAiIsqMbYjsT5e-T7KzowPTAAAAAAEMAAAiIsqMbYjsT5e-T7KzowPTAAMCzwJpAAA=', - sanitized: 'https://graph.microsoft.com/v1.0/me/messages/{messages-id}' - }, - { - check: 'without extension id', - url: - 'https://graph.microsoft.com/v1.0/me/extensions/com.contoso.roamingSettings', - sanitized: - 'https://graph.microsoft.com/v1.0/me/extensions/{extensions-id}' - }, - { - check: 'without plan id', - url: - 'https://graph.microsoft.com/v1.0/planner/plans/CONGZUWfGUu4msTgNP66e2UAAySi', - sanitized: 'https://graph.microsoft.com/v1.0/planner/plans/{plans-id}' - }, - { - check: 'without section id', - url: - 'https://graph.microsoft.com/v1.0/me/onenote/sections/1f7ff346-c174-45e5-af38-294e51d9969a/pages', - sanitized: - 'https://graph.microsoft.com/v1.0/me/onenote/sections/{sections-id}/pages' - }, - { - check: 'with all parameters replaced', - // eslint-disable-next-line max-len - url: 'https://graph.microsoft.com/v1.0/teams/02bd9fd6-8f93-4758-87c3-1fb73740a315/channels/19:09fc54a3141a45d0bc769cf506d2e079@thread.skype', - sanitized: - 'https://graph.microsoft.com/v1.0/teams/{teams-id}/channels/{channels-id}' - }, - { - check: 'with depracated resource and without id', - url: - 'https://graph.microsoft.com/v1.0/applications_v2/02bd9fd6-8f93-4758-87c3-1fb73740a315', - sanitized: - 'https://graph.microsoft.com/v1.0/applications_v2/{applications_v2-id}' - } - ]; - - list.forEach((element) => { - it(`return url ${element.check}`, () => { - const sanitizedUrl = sanitizeQueryUrl(element.url); - expect(sanitizedUrl).toEqual(element.sanitized); - }); - }); -}); diff --git a/src/tests/utils/theme-utils.spec.ts b/src/themes/theme-utils.spec.ts similarity index 74% rename from src/tests/utils/theme-utils.spec.ts rename to src/themes/theme-utils.spec.ts index 4fb1d6a6b..fd26b193e 100644 --- a/src/tests/utils/theme-utils.spec.ts +++ b/src/themes/theme-utils.spec.ts @@ -1,4 +1,5 @@ -import { saveTheme, readTheme } from '../../../src/themes/theme-utils'; +import { saveTheme, readTheme } from './theme-utils'; + describe('Tests theme utils', () => { it('Saves theme to local storage then retrieves the saved theme', () => { const theme = 'dark';