Add one test case for update user form

This commit is contained in:
roschaefer 2019-09-20 20:30:57 +02:00
parent e8f47cb004
commit c378505293
2 changed files with 33 additions and 3 deletions

View File

@ -5,7 +5,12 @@ export default function UniqueSlugForm({ translate, apollo, currentUser }) {
return {
formSchema: {
slug: [
{type: "string", required: true, pattern: /^[a-z0-9_-]+$/, message: translate('settings.validation.slug.regex') },
{
type: 'string',
required: true,
pattern: /^[a-z0-9_-]+$/,
message: translate('settings.validation.slug.regex'),
},
{
asyncValidator(rule, value, callback) {
debounce(() => {

View File

@ -59,9 +59,34 @@ describe('index.vue', () => {
expect(Wrapper().contains('div')).toBe(true)
})
describe('given we bypass the slug validations', () => {
describe('given form validation errors', () => {
beforeEach(() => {
options = {
...options,
computed: {
formSchema: () => ({
slug: [
(_rule, _value, callback) => {
callback(new Error('Ouch!'))
},
],
}),
},
}
})
it('cannot call updateUser mutation', () => {
const wrapper = Wrapper()
wrapper.find('#name').setValue('Peter')
wrapper.find('.ds-form').trigger('submit')
expect(mocks.$apollo.mutate).not.toHaveBeenCalled()
})
})
describe('no form validation errors', () => {
beforeEach(() => {
// I gave up after 3 hours, feel free to remove the line below
options = { ...options, computed: { formSchema: () => ({}) } }
})