Skip to content

Commit b43978c

Browse files
committed
fix tests due to missing vscode slice
unfortunately, mockStates does not have "satisfies OverallState"
1 parent 14c8eb7 commit b43978c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/commons/sagas/BackendSaga.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function* routerNavigate(path: string) {
121121
const newBackendSagaOne = combineSagaHandlers({
122122
[SessionActions.fetchAuth.type]: function* (action): any {
123123
const { code, providerId: payloadProviderId } = action.payload;
124-
const isVscode = yield select(state => state.vscode.isVscode);
124+
const isVscode: boolean = yield select((state: OverallState) => state.vscode.isVscode);
125125

126126
const providerId = payloadProviderId || (getDefaultProvider() || [null])[0];
127127
if (!providerId) {

src/commons/sagas/__tests__/BackendSaga.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ const mockRouter = createMemoryRouter([
240240
}
241241
]);
242242

243+
const mockVscodeSlice = {
244+
vscode: {
245+
isVscode: false
246+
}
247+
};
248+
243249
const mockStates = {
244250
router: mockRouter,
245251
session: {
@@ -255,7 +261,8 @@ const mockStates = {
255261
},
256262
workspaces: {
257263
assessment: { currentAssessment: mockAssessment.id }
258-
}
264+
},
265+
...mockVscodeSlice
259266
};
260267

261268
const okResp = { ok: true };
@@ -362,7 +369,7 @@ describe('Test FETCH_AUTH action', () => {
362369
}
363370
]
364371
])
365-
.withState({ session: mockTokens }) // need to mock tokens for updateLatestViewedCourse call
372+
.withState({ session: mockTokens, ...mockVscodeSlice }) // need to mock tokens for updateLatestViewedCourse call
366373
.call(postAuth, code, providerId, clientId, redirectUrl)
367374
.put(SessionActions.setTokens(mockTokens))
368375
.call(getUser, mockTokens)
@@ -377,7 +384,7 @@ describe('Test FETCH_AUTH action', () => {
377384

378385
test('when user is null', () => {
379386
return expectSaga(BackendSaga)
380-
.withState({ session: mockTokens }) // need to mock tokens for the selectTokens() call
387+
.withState({ session: mockTokens, ...mockVscodeSlice }) // need to mock tokens for the selectTokens() call
381388
.provide([
382389
[call(postAuth, code, providerId, clientId, redirectUrl), mockTokens],
383390
[

0 commit comments

Comments
 (0)