Skip to content

Commit

Permalink
Fix App callCount test by no longer stubbing free-standing function g…
Browse files Browse the repository at this point in the history
…etCurrentUser due to version change

It turns out that you can no longer stub free-standing functions in Typescript 3.9.2+ according to this issue:

microsoft/TypeScript#38568
sinonjs/sinon#562

The test in App.test.tsx was failing when it tried to get the callCount for a stub for a free-standing function getCurrentUser, and currently, my package-lock.json has 3.9.5, so that appears to be why. My fix was to use an object where the functions become methods instead.
  • Loading branch information
natalynyu committed Sep 11, 2020
1 parent 75c7cdd commit aaa3961
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/client/components/App.tsx
Expand Up @@ -32,7 +32,7 @@ import {
PageTitle,
Link,
} from 'mark-one';
import { getCurrentUser } from 'client/api';
import { UserAPI } from 'client/api';
import { UserResponse } from 'common/dto/users/userResponse.dto';
import { MetadataContext } from 'client/context/MetadataContext';
import { getMetadata } from 'client/api/metadata';
Expand Down Expand Up @@ -77,8 +77,8 @@ export const ColdApp: SFC = (): ReactElement => {
*/

useEffect((): void => {
getCurrentUser()
.then((user): UserResponse => {
UserAPI.getCurrentUser()
.then(({ data: user }): UserResponse => {
setUser(user);
return user;
})
Expand Down

0 comments on commit aaa3961

Please sign in to comment.