Skip to content

Commit

Permalink
chore(project): tests fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLantukh committed Jul 24, 2023
1 parent 32f00b0 commit 5bcafb7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 69 deletions.
45 changes: 26 additions & 19 deletions src/components/LoginForm/LoginForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,35 @@ import LoginForm from './LoginForm';

import { createWrapper, waitForWithFakeTimers } from '#test/testUtils';

vi.mock('../SocialButton/SocialButton.tsx', () => ({
default: (props: { href: string }) => {
return <a href={props.href}>Social Button</a>;
},
}));

vi.mock('#src/stores/AccountController', async (importOriginal) => {
const mod = await importOriginal();

return {
...(mod as Record<string, unknown>),
getSocialLoginUrls: () =>
Promise.resolve([
{
twitter: 'https://staging-v2.inplayer.com/',
},
{
facebook: 'https://www.facebook.com/',
},
{
google: 'https://accounts.google.com/',
},
]),
};
});

describe('<LoginForm>', () => {
beforeEach(() => {
vi.useFakeTimers();
vi.mock('#src/stores/AccountController', async (importOriginal) => {
const mod = await importOriginal();

return {
...(mod as Record<string, unknown>),
getSocialLoginUrls: () =>
Promise.resolve([
{
twitter: 'https://staging-v2.inplayer.com/',
},
{
facebook: 'https://www.facebook.com/',
},
{
google: 'https://accounts.google.com/',
},
]),
};
});
});

test('renders and matches snapshot', async () => {
Expand Down
51 changes: 3 additions & 48 deletions src/components/LoginForm/__snapshots__/LoginForm.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,19 @@ exports[`<LoginForm> > renders and matches snapshot 1`] = `
class="_socialButtonsListContainer_313d0d"
>
<a
aria-label="login.twitter"
class="_socialButtonContainer_b830cd"
href="https://staging-v2.inplayer.com/"
>
<div
class="_socialButtonIconContainer_b830cd"
>
<img
alt="twitter icon"
class="_socialButtonIcon_b830cd"
src=""
/>
</div>
<span
class="_socialButtonTextContainer_b830cd"
>
login.twitter
</span>
Social Button
</a>
<a
aria-label="login.facebook"
class="_socialButtonContainer_b830cd"
href="https://www.facebook.com/"
>
<div
class="_socialButtonIconContainer_b830cd"
>
<img
alt="facebook icon"
class="_socialButtonIcon_b830cd"
src=""
/>
</div>
<span
class="_socialButtonTextContainer_b830cd"
>
login.facebook
</span>
Social Button
</a>
<a
aria-label="login.google"
class="_socialButtonContainer_b830cd"
href="https://accounts.google.com/"
>
<div
class="_socialButtonIconContainer_b830cd"
>
<img
alt="google icon"
class="_socialButtonIcon_b830cd"
src=""
/>
</div>
<span
class="_socialButtonTextContainer_b830cd"
>
login.google
</span>
Social Button
</a>
</div>
<h2
Expand Down
2 changes: 0 additions & 2 deletions src/pages/User/User.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ describe('User Component tests', () => {

test('Account Page', () => {
useAccountStore.setState(data);
mockWindowLocation('my-account');

mockWindowLocation('my-account');
const { container } = renderWithRouter(<User />);

Expand Down

0 comments on commit 5bcafb7

Please sign in to comment.