mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-29 18:46:20 -05:00
WIP trying to fix tests
This commit is contained in:
parent
652871f0bd
commit
420e7dfa3e
1 changed files with 14 additions and 5 deletions
|
@ -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')
|
||||||
|
|
Loading…
Reference in a new issue