fix some tests

This commit is contained in:
Moriz Wahl 2022-07-25 22:53:19 +02:00
parent bc955003f7
commit 5393c2aeaa
3 changed files with 13 additions and 8 deletions

View File

@ -58,6 +58,9 @@ describe('ContributionForm.vue', () => {
back: jest.fn(),
push: jest.fn(),
},
$env: {
CATEGORIES_ACTIVE: false,
},
}
propsData = {}
})
@ -132,6 +135,7 @@ describe('ContributionForm.vue', () => {
variables: {
title: postTitle,
content: postContent,
categoryIds: [],
id: null,
image: null,
},
@ -254,6 +258,7 @@ describe('ContributionForm.vue', () => {
variables: {
title: propsData.contribution.title,
content: propsData.contribution.content,
categoryIds: [],
id: propsData.contribution.id,
image: {
sensitive: false,

View File

@ -126,9 +126,9 @@ export default {
imageBlurred: { required: false },
categoryIds: {
type: 'array',
required: true,
required: this.categoriesActive,
validator: (_, value = []) => {
if (value.length === 0 || value.length > 3) {
if (this.categoriesActive && (value.length === 0 || value.length > 3)) {
return [new Error(this.$t('common.validations.categories'))]
}
return []

View File

@ -5,13 +5,13 @@ const localVue = global.localVue
describe('create.vue', () => {
let wrapper
let mocks
beforeEach(() => {
mocks = {
$t: jest.fn(),
}
})
const mocks = {
$t: jest.fn(),
$env: {
CATEGORIES_ACTIVE: false,
},
}
describe('mount', () => {
const Wrapper = () => {