WIP trying to fix tests

This commit is contained in:
Ben Wheeler 2019-10-30 15:34:52 -04:00
parent 652871f0bd
commit 420e7dfa3e

View file

@ -1,9 +1,9 @@
const React = require('react'); const React = require('react');
const {shallowWithIntl} = require('../../helpers/intl-helpers.jsx'); const {shallowWithIntl} = require('../../helpers/intl-helpers.jsx');
const mockedValidateUsernameRemotely = jest.fn(() => ( let mockedValidateUsernameRemotely = jest.fn(() => (
/* eslint-disable no-undef */ /* eslint-disable no-undef */
Promise.resolve({valid: false, errMsgId: 'registration.validationUsernameNotAllowed'}) Promise.resolve({requestSucceeded: true, valid: false, errMsgId: 'registration.validationUsernameNotAllowed'})
/* eslint-enable no-undef */ /* eslint-enable no-undef */
)); ));
@ -17,7 +17,7 @@ jest.mock('../../../src/lib/validate.js', () => (
// must come after validation mocks, so validate.js will be mocked before it is required // must come after validation mocks, so validate.js will be mocked before it is required
const UsernameStep = require('../../../src/components/join-flow/username-step.jsx'); const UsernameStep = require('../../../src/components/join-flow/username-step.jsx');
describe('UsernameStep test', () => { describe('UsernameStep tests', () => {
afterEach(() => { afterEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
@ -54,9 +54,18 @@ describe('UsernameStep test', () => {
expect(mockedOnNextStep).toHaveBeenCalledWith(formData); expect(mockedOnNextStep).toHaveBeenCalledWith(formData);
}); });
});
describe('validateUsernameRemotelyWithCache test', () => {
// mockedValidateUsernameRemotely = jest.fn(() => (
// /* eslint-disable no-undef */
// Promise.resolve({requestSucceeded: true, valid: false, errMsgId: 'registration.validationUsernameNotAllowed'})
// /* eslint-enable no-undef */
// ));
test('validateUsernameRemotelyWithCache calls validate.validateUsernameRemotely', done => { test('validateUsernameRemotelyWithCache calls validate.validateUsernameRemotely', done => {
const wrapper = shallowWithIntl( const wrapper = shallowWithIntl(<UsernameStep />);
<UsernameStep />);
const instance = wrapper.dive().instance(); const instance = wrapper.dive().instance();
instance.validateUsernameRemotelyWithCache('newUniqueUsername55') instance.validateUsernameRemotelyWithCache('newUniqueUsername55')