remove .map files from production build
show error message if wrong password was entered.
This commit is contained in:
@ -4,18 +4,53 @@ import {shallow} from 'enzyme';
|
||||
|
||||
describe('<AuthenticationPage/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
const wrapper = shallow(<AuthenticationPage submit={() => {}}/>);
|
||||
const wrapper = shallow(<AuthenticationPage submit={() => {
|
||||
}}/>);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('test button click', function () {
|
||||
let pass;
|
||||
const func = jest.fn((pwd) => {pass = pwd});
|
||||
const wrapper = shallow(<AuthenticationPage submit={func}/>);
|
||||
const func = jest.fn();
|
||||
const wrapper = shallow(<AuthenticationPage onSuccessLogin={func}/>);
|
||||
wrapper.instance().authenticate = jest.fn(() => {
|
||||
wrapper.instance().props.onSuccessLogin()
|
||||
});
|
||||
wrapper.setState({pwdText: 'testpwd'});
|
||||
|
||||
wrapper.find('Button').simulate('click');
|
||||
|
||||
expect(func).toHaveBeenCalledTimes(1);
|
||||
expect(pass).toBe('testpwd');
|
||||
});
|
||||
|
||||
it('test fail authenticate', function () {
|
||||
const events = mockKeyPress();
|
||||
|
||||
const helpers = require('../../utils/Api');
|
||||
helpers.refreshAPIToken = jest.fn().mockImplementation((callback, force, pwd) => {
|
||||
callback('there was an error')
|
||||
});
|
||||
|
||||
const wrapper = shallow(<AuthenticationPage/>);
|
||||
|
||||
events.keyup({key: 'Enter'});
|
||||
|
||||
expect(wrapper.state().wrongPWDInfo).toBe(true);
|
||||
});
|
||||
|
||||
it('test success authenticate', function () {
|
||||
const events = mockKeyPress();
|
||||
const func = jest.fn()
|
||||
|
||||
const helpers = require('../../utils/Api');
|
||||
helpers.refreshAPIToken = jest.fn().mockImplementation((callback, force, pwd) => {
|
||||
callback('')
|
||||
});
|
||||
|
||||
const wrapper = shallow(<AuthenticationPage onSuccessLogin={func}/>);
|
||||
|
||||
events.keyup({key: 'Enter'});
|
||||
|
||||
expect(wrapper.state().wrongPWDInfo).toBe(false);
|
||||
expect(func).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user