mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-12-04 12:51:28 -05:00
ba99d49298
Add strings
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
import React from 'react';
|
|
import {mountWithIntl} from '../../helpers/intl-helpers.jsx';
|
|
import FeedbackForm from '../../../src/components/modal/mute/feedback-form';
|
|
|
|
describe('FeedbackFormTest', () => {
|
|
test('Feedback form empty feedback invalid', () => {
|
|
const submitFn = jest.fn();
|
|
const message = 'too short';
|
|
const component = mountWithIntl(
|
|
<FeedbackForm
|
|
emptyErrorMessage={message}
|
|
onSubmit={submitFn}
|
|
/>
|
|
);
|
|
expect(component.find('FeedbackForm').instance()
|
|
.validateFeedback('')
|
|
).toBe(message);
|
|
});
|
|
|
|
test('Feedback form shorter than minLength invalid', () => {
|
|
const submitFn = jest.fn();
|
|
const message = 'too short';
|
|
const min = 7;
|
|
const component = mountWithIntl(
|
|
<FeedbackForm
|
|
emptyErrorMessage={message}
|
|
minLength={min}
|
|
onSubmit={submitFn}
|
|
/>
|
|
);
|
|
|
|
expect(component.find('FeedbackForm').instance()
|
|
.validateFeedback('123456')
|
|
).toBe(message);
|
|
});
|
|
|
|
test('Feedback form greater than or equal to minLength invalid', () => {
|
|
const submitFn = jest.fn();
|
|
const message = 'too short';
|
|
const min = 7;
|
|
const component = mountWithIntl(
|
|
<FeedbackForm
|
|
emptyErrorMessage={message}
|
|
minLength={min}
|
|
onSubmit={submitFn}
|
|
/>
|
|
);
|
|
|
|
expect(component.find('FeedbackForm').instance()
|
|
.validateFeedback('1234567')
|
|
).toBeNull();
|
|
});
|
|
});
|