-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display error for all enterprise connections in the reset password sc…
…reen
- Loading branch information
Showing
3 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/__tests__/connection/database/__snapshots__/reset_password.test.jsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ResetPasswordScreen isSubmitDisabled returns false when \`isEnterpriseDomain\` is false 1`] = ` | ||
Array [ | ||
"updateEntity", | ||
"lock", | ||
"id", | ||
"clearGlobalError", | ||
] | ||
`; | ||
|
||
exports[`ResetPasswordScreen isSubmitDisabled returns true when \`isEnterpriseDomain\` is true 1`] = ` | ||
Array [ | ||
"updateEntity", | ||
"lock", | ||
"id", | ||
"setGlobalError", | ||
"error,forgotPassword,enterprise_email", | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
|
||
const getScreen = () => { | ||
const ResetPasswordScreen = require('connection/database/reset_password').default; | ||
return new ResetPasswordScreen(); | ||
}; | ||
|
||
describe('ResetPasswordScreen', () => { | ||
beforeEach(() => { | ||
jest.resetModules(); | ||
|
||
jest.mock('connection/database/index', () => ({ | ||
databaseUsernameValue: () => 'foo@test.com' | ||
})); | ||
|
||
jest.mock('connection/enterprise', () => ({ | ||
isEnterpriseDomain: () => true | ||
})); | ||
|
||
jest.mock('i18n', () => ({ str: (_, keys) => keys.join(',') })); | ||
|
||
jest.mock('core/index', () => ({ | ||
id: () => 'id', | ||
setGlobalError: 'setGlobalError', | ||
clearGlobalError: 'clearGlobalError' | ||
})); | ||
|
||
jest.mock('store/index', () => ({ | ||
swap: jest.fn(), | ||
updateEntity: 'updateEntity' | ||
})); | ||
}); | ||
it('isSubmitDisabled returns true when `isEnterpriseDomain` is true', () => { | ||
const screen = getScreen(); | ||
expect(screen.isSubmitDisabled()).toBe(true); | ||
expect(require('store/index').swap.mock.calls[0]).toMatchSnapshot(); | ||
}); | ||
it('isSubmitDisabled returns false when `isEnterpriseDomain` is false', () => { | ||
require('connection/enterprise').isEnterpriseDomain = () => false; | ||
const screen = getScreen(); | ||
expect(screen.isSubmitDisabled()).toBe(false); | ||
expect(require('store/index').swap.mock.calls[0]).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters