Skip to content

Commit

Permalink
AuhtenticationPage.test.js: add tests for showing Google or Facebook …
Browse files Browse the repository at this point in the history
…or both
  • Loading branch information
OtterleyW committed Nov 2, 2020
1 parent f8aa41c commit 6b89b4d
Show file tree
Hide file tree
Showing 2 changed files with 589 additions and 1 deletion.
94 changes: 93 additions & 1 deletion src/containers/AuthenticationPage/AuthenticationPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,102 @@ import { AuthenticationPageComponent } from './AuthenticationPage';
const noop = () => null;

describe('AuthenticationPageComponent', () => {
// We need to overwrite REACT_APP_FACEBOOK_APP_ID before running the test
// We need to overwrite social login client ids before running the test
// to make sure it's same in local environment and in CI
beforeEach(() => {
process.env = Object.assign(process.env, { REACT_APP_FACEBOOK_APP_ID: '' });
process.env = Object.assign(process.env, { REACT_APP_GOOGLE_CLIENT_ID: '' });
});

it('matches snapshot', () => {
const props = {
history: { push: noop },
location: { state: { from: '/protected' } },
tab: 'login',
isAuthenticated: false,
authInProgress: false,
scrollingDisabled: false,
currentUserHasListings: false,
onLogout: noop,
onManageDisableScrolling: noop,
submitLogin: noop,
submitSignup: noop,
intl: fakeIntl,
sendVerificationEmailInProgress: false,
onResendVerificationEmail: noop,
};
const tree = renderShallow(<AuthenticationPageComponent {...props} />);
expect(tree).toMatchSnapshot();
});
});


describe('AuthenticationPageComponent with Facebook login', () => {
// We need to overwrite social login client ids before running the test
// to make sure it's same in local environment and in CI
beforeEach(() => {
process.env = Object.assign(process.env, { REACT_APP_FACEBOOK_APP_ID: 'test' });
process.env = Object.assign(process.env, { REACT_APP_GOOGLE_CLIENT_ID: '' });
});

it('matches snapshot', () => {
const props = {
history: { push: noop },
location: { state: { from: '/protected' } },
tab: 'login',
isAuthenticated: false,
authInProgress: false,
scrollingDisabled: false,
currentUserHasListings: false,
onLogout: noop,
onManageDisableScrolling: noop,
submitLogin: noop,
submitSignup: noop,
intl: fakeIntl,
sendVerificationEmailInProgress: false,
onResendVerificationEmail: noop,
};
const tree = renderShallow(<AuthenticationPageComponent {...props} />);
expect(tree).toMatchSnapshot();
});
});

describe('AuthenticationPageComponent with Google login', () => {
// We need to overwrite social login client ids before running the test
// to make sure it's same in local environment and in CI
beforeEach(() => {
process.env = Object.assign(process.env, { REACT_APP_FACEBOOK_APP_ID: '' });
process.env = Object.assign(process.env, { REACT_APP_GOOGLE_CLIENT_ID: 'test' });
});

it('matches snapshot', () => {
const props = {
history: { push: noop },
location: { state: { from: '/protected' } },
tab: 'login',
isAuthenticated: false,
authInProgress: false,
scrollingDisabled: false,
currentUserHasListings: false,
onLogout: noop,
onManageDisableScrolling: noop,
submitLogin: noop,
submitSignup: noop,
intl: fakeIntl,
sendVerificationEmailInProgress: false,
onResendVerificationEmail: noop,
};
const tree = renderShallow(<AuthenticationPageComponent {...props} />);
expect(tree).toMatchSnapshot();
});
});

describe('AuthenticationPageComponent with Google and Facebook login', () => {
// We need to overwrite social login client ids before running the test
// to make sure it's same in local environment and in CI
beforeEach(() => {
process.env = Object.assign(process.env, { REACT_APP_FACEBOOK_APP_ID: 'test' });
process.env = Object.assign(process.env, { REACT_APP_GOOGLE_CLIENT_ID: 'test' });
});

it('matches snapshot', () => {
Expand Down
Loading

0 comments on commit 6b89b4d

Please sign in to comment.