mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Add one test case for update user form
This commit is contained in:
parent
e8f47cb004
commit
c378505293
@ -5,7 +5,12 @@ export default function UniqueSlugForm({ translate, apollo, currentUser }) {
|
|||||||
return {
|
return {
|
||||||
formSchema: {
|
formSchema: {
|
||||||
slug: [
|
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) {
|
asyncValidator(rule, value, callback) {
|
||||||
debounce(() => {
|
debounce(() => {
|
||||||
|
|||||||
@ -59,9 +59,34 @@ describe('index.vue', () => {
|
|||||||
expect(Wrapper().contains('div')).toBe(true)
|
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(() => {
|
beforeEach(() => {
|
||||||
// I gave up after 3 hours, feel free to remove the line below
|
|
||||||
options = { ...options, computed: { formSchema: () => ({}) } }
|
options = { ...options, computed: { formSchema: () => ({}) } }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user