Skip to content

Commit

Permalink
chore(jest): use function instead of jest.fn
Browse files Browse the repository at this point in the history
  • Loading branch information
amen-souissi committed Mar 15, 2021
1 parent 79a472a commit e61bbe2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@decathlon/moon-testing",
"version": "0.0.2",
"version": "0.1.0",
"description": "Moon testing utilities.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ export class AxiosClient {
}

export function mockAxiosClientConstructor(ClientFactory = AxiosClient): void {
Axios.create = jest.fn().mockImplementation(({ baseUrl }) => {
Axios.create = ({ baseUrl }) => {
return new ClientFactory(baseUrl);
});
};
}

mockAxiosClientConstructor(AxiosClient);

export const cancelToken = { cancel: () => jest.fn() };

StaticAxios.CancelToken.source = jest.fn().mockReturnValue(cancelToken);
StaticAxios.CancelToken.source = () => cancelToken;

export { default as MoonClient } from "./moon-client";
export * from "./moon-client";
Expand Down

0 comments on commit e61bbe2

Please sign in to comment.