From 26954e809d42b26712b006491d8c79fee09ff377 Mon Sep 17 00:00:00 2001 From: Marcos Iglesias <190833+Golodhros@users.noreply.github.com> Date: Thu, 13 Aug 2020 09:35:19 -0700 Subject: [PATCH] Fixes TypeScript issues with sagas and saga tests (#573) Signed-off-by: Marcos Iglesias --- amundsen_application/static/global.d.ts | 2 ++ .../js/ducks/bookmark/{tests => }/index.spec.ts | 8 ++++---- .../static/js/ducks/bookmark/sagas.ts | 2 +- .../static/js/ducks/user/{tests => }/index.spec.ts | 12 ++++++------ amundsen_application/static/package-lock.json | 12 ++++++------ amundsen_application/static/package.json | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) rename amundsen_application/static/js/ducks/bookmark/{tests => }/index.spec.ts (99%) rename amundsen_application/static/js/ducks/user/{tests => }/index.spec.ts (98%) diff --git a/amundsen_application/static/global.d.ts b/amundsen_application/static/global.d.ts index dc9d186bb..b7a12826b 100644 --- a/amundsen_application/static/global.d.ts +++ b/amundsen_application/static/global.d.ts @@ -1,3 +1,5 @@ +export {}; + declare const require: { (path: string): T; (paths: string[], callback: (...modules: any[]) => void): void; diff --git a/amundsen_application/static/js/ducks/bookmark/tests/index.spec.ts b/amundsen_application/static/js/ducks/bookmark/index.spec.ts similarity index 99% rename from amundsen_application/static/js/ducks/bookmark/tests/index.spec.ts rename to amundsen_application/static/js/ducks/bookmark/index.spec.ts index ee87aed61..bcd8c5eb3 100644 --- a/amundsen_application/static/js/ducks/bookmark/tests/index.spec.ts +++ b/amundsen_application/static/js/ducks/bookmark/index.spec.ts @@ -4,7 +4,7 @@ import { throwError } from 'redux-saga-test-plan/providers'; import { Bookmark, ResourceType, ResourceDict } from 'interfaces'; -import * as API from '../api/v0'; +import * as API from './api/v0'; import reducer, { addBookmark, addBookmarkFailure, @@ -21,7 +21,7 @@ import reducer, { initialState, initialBookmarkState, BookmarkReducerState, -} from '../reducer'; +} from './reducer'; import { addBookmarkWatcher, addBookmarkWorker, @@ -31,7 +31,7 @@ import { getBookmarkForUserWorker, removeBookmarkWatcher, removeBookmarkWorker, -} from '../sagas'; +} from './sagas'; import { AddBookmark, AddBookmarkRequest, @@ -40,7 +40,7 @@ import { GetBookmarksForUserRequest, RemoveBookmark, RemoveBookmarkRequest, -} from '../types'; +} from './types'; describe('bookmark ducks', () => { let bookmarks: ResourceDict; diff --git a/amundsen_application/static/js/ducks/bookmark/sagas.ts b/amundsen_application/static/js/ducks/bookmark/sagas.ts index f0f77e59d..6860d52ce 100644 --- a/amundsen_application/static/js/ducks/bookmark/sagas.ts +++ b/amundsen_application/static/js/ducks/bookmark/sagas.ts @@ -59,7 +59,7 @@ export function* removeBookmarkWatcher(): SagaIterator { yield takeEvery(RemoveBookmark.REQUEST, removeBookmarkWorker); } -export function* getBookmarksWorker(action: GetBookmarksRequest): SagaIterator { +export function* getBookmarksWorker(): SagaIterator { let response; try { response = yield call(API.getBookmarks); diff --git a/amundsen_application/static/js/ducks/user/tests/index.spec.ts b/amundsen_application/static/js/ducks/user/index.spec.ts similarity index 98% rename from amundsen_application/static/js/ducks/user/tests/index.spec.ts rename to amundsen_application/static/js/ducks/user/index.spec.ts index 7ebfacfce..9aad51ea9 100644 --- a/amundsen_application/static/js/ducks/user/tests/index.spec.ts +++ b/amundsen_application/static/js/ducks/user/index.spec.ts @@ -4,7 +4,7 @@ import { LoggedInUser, PeopleUser, Resource, ResourceDict } from 'interfaces'; import globalState from 'fixtures/globalState'; -import * as API from '../api/v0'; +import * as API from './api/v0'; import reducer, { getLoggedInUser, getLoggedInUserFailure, @@ -22,7 +22,7 @@ import reducer, { initialState, initialOwnState, UserReducerState, -} from '../reducer'; +} from './reducer'; import { getLoggedInUserWorker, getLoggedInUserWatcher, @@ -32,8 +32,8 @@ import { getUserOwnWatcher, getUserReadWorker, getUserReadWatcher, -} from '../sagas'; -import { GetLoggedInUser, GetUser, GetUserOwn, GetUserRead } from '../types'; +} from './sagas'; +import { GetLoggedInUser, GetUser, GetUserOwn, GetUserRead } from './types'; describe('user ducks', () => { let currentUser: LoggedInUser; @@ -247,7 +247,7 @@ describe('user ducks', () => { describe('getLoggedInUserWorker', () => { it('executes flow for returning the currentUser', () => { - testSaga(getLoggedInUserWorker, getLoggedInUser()) + testSaga(getLoggedInUserWorker) .next() .call(API.getLoggedInUser) .next(currentUser) @@ -257,7 +257,7 @@ describe('user ducks', () => { }); it('handles request error', () => { - testSaga(getLoggedInUserWorker, getLoggedInUser()) + testSaga(getLoggedInUserWorker) .next() .throw(new Error()) .put(getLoggedInUserFailure()) diff --git a/amundsen_application/static/package-lock.json b/amundsen_application/static/package-lock.json index 29d5d81ce..56a781675 100644 --- a/amundsen_application/static/package-lock.json +++ b/amundsen_application/static/package-lock.json @@ -12245,7 +12245,7 @@ }, "css-select": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", "dev": true, "requires": { @@ -12759,7 +12759,7 @@ "dependencies": { "domelementtype": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", "dev": true } @@ -27515,9 +27515,9 @@ } }, "redux-saga-test-plan": { - "version": "4.0.0-beta.3", - "resolved": "https://registry.npmjs.org/redux-saga-test-plan/-/redux-saga-test-plan-4.0.0-beta.3.tgz", - "integrity": "sha512-nOA2MsUHlp5JGlGhDo8IbVnKXIh1qLCE4vZE5rz1wvdXLMEk6F9QwfI1LbdaBT0XdrxjeI+JjeUAMZ5sgYfeTA==", + "version": "4.0.0-rc.3", + "resolved": "https://registry.npmjs.org/redux-saga-test-plan/-/redux-saga-test-plan-4.0.0-rc.3.tgz", + "integrity": "sha512-18Ha1AWmP4Xt64cSyJv2j7sH8lwQzdk/LByiyhoNyuqyhzkQzlKlflHr3LqiSCzn3e2AgFxagynto8XGRqsHcg==", "dev": true, "requires": { "core-js": "^2.4.1", @@ -31866,7 +31866,7 @@ "dependencies": { "json5": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/json5/-/json5-1.0.1.tgz", "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "dev": true, "requires": { diff --git a/amundsen_application/static/package.json b/amundsen_application/static/package.json index f324c2297..47df13cd5 100644 --- a/amundsen_application/static/package.json +++ b/amundsen_application/static/package.json @@ -96,7 +96,7 @@ "react-docgen-typescript-loader": "^3.7.2", "redux-mock-store": "^1.5.4", "redux-saga": "^1.1.3", - "redux-saga-test-plan": "4.0.0-beta.3", + "redux-saga-test-plan": "4.0.0-rc.3", "sass-loader": "^7.3.1", "style-loader": "^0.20.3", "stylelint": "^13.6.0",