From 420e7dfa3e28ea6b0e66a813a0d8060a1c61f45f Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Wed, 30 Oct 2019 15:34:52 -0400 Subject: [PATCH] WIP trying to fix tests --- test/unit/components/username-step.test.jsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/test/unit/components/username-step.test.jsx b/test/unit/components/username-step.test.jsx index c64045a12..695ed8b06 100644 --- a/test/unit/components/username-step.test.jsx +++ b/test/unit/components/username-step.test.jsx @@ -1,9 +1,9 @@ const React = require('react'); const {shallowWithIntl} = require('../../helpers/intl-helpers.jsx'); -const mockedValidateUsernameRemotely = jest.fn(() => ( +let mockedValidateUsernameRemotely = jest.fn(() => ( /* eslint-disable no-undef */ - Promise.resolve({valid: false, errMsgId: 'registration.validationUsernameNotAllowed'}) + Promise.resolve({requestSucceeded: true, valid: false, errMsgId: 'registration.validationUsernameNotAllowed'}) /* 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 const UsernameStep = require('../../../src/components/join-flow/username-step.jsx'); -describe('UsernameStep test', () => { +describe('UsernameStep tests', () => { afterEach(() => { jest.clearAllMocks(); @@ -54,9 +54,18 @@ describe('UsernameStep test', () => { 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 => { - const wrapper = shallowWithIntl( - ); + const wrapper = shallowWithIntl(); const instance = wrapper.dive().instance(); instance.validateUsernameRemotelyWithCache('newUniqueUsername55')