Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gao-sun committed Sep 9, 2022
1 parent dfc8277 commit 9deef19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions packages/react/src/hooks/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-function */
import LogtoClient from '@logto/browser';
import { renderHook, act } from '@testing-library/react-hooks';
import { ComponentType } from 'react';
Expand All @@ -8,7 +7,7 @@ import { LogtoProvider } from '../provider';

const isAuthenticated = jest.fn(() => false);
const isSignInRedirected = jest.fn(() => false);
const handleSignInCallback = jest.fn(async () => 0);
const handleSignInCallback = jest.fn().mockResolvedValue(true);
const getAccessToken = jest.fn(() => {
throw new Error('not authenticated');
});
Expand All @@ -20,8 +19,8 @@ jest.mock('@logto/browser', () => {
isSignInRedirected,
handleSignInCallback,
getAccessToken,
signIn: jest.fn(async () => {}),
signOut: jest.fn(async () => {}),
signIn: jest.fn().mockResolvedValue(true),
signOut: jest.fn().mockResolvedValue(true),
};
});
});
Expand Down Expand Up @@ -111,4 +110,3 @@ describe('useLogto', () => {
});
});
});
/* eslint-enable @typescript-eslint/no-empty-function */
8 changes: 3 additions & 5 deletions packages/vue/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-function */
import LogtoClient from '@logto/browser';
import { App, readonly } from 'vue';

Expand All @@ -9,7 +8,7 @@ import { createPluginMethods } from './plugin';

const isAuthenticated = jest.fn(async () => false);
const isSignInRedirected = jest.fn(() => false);
const handleSignInCallback = jest.fn(async () => {});
const handleSignInCallback = jest.fn().mockResolvedValue(true);
const getAccessToken = jest.fn(() => {
throw new Error('not authenticated');
});
Expand All @@ -24,8 +23,8 @@ jest.mock('@logto/browser', () => {
isSignInRedirected,
handleSignInCallback,
getAccessToken,
signIn: jest.fn(async () => {}),
signOut: jest.fn(async () => {}),
signIn: jest.fn().mockResolvedValue(true),
signOut: jest.fn().mockResolvedValue(true),
};
});
});
Expand Down Expand Up @@ -151,4 +150,3 @@ describe('useHandleSignInCallback', () => {
expect(handleSignInCallback).toHaveBeenCalledTimes(1);
});
});
/* eslint-enable @typescript-eslint/no-empty-function */

0 comments on commit 9deef19

Please sign in to comment.