diff --git a/packages/cozy-client/src/models/document/qualification.spec.js b/packages/cozy-client/src/models/document/qualification.spec.js index 9016e9de23..53bf6c5735 100644 --- a/packages/cozy-client/src/models/document/qualification.spec.js +++ b/packages/cozy-client/src/models/document/qualification.spec.js @@ -6,6 +6,42 @@ import { import * as qualificationModel from '../../assets/qualifications.json' import logger from '../../logger' +jest.mock('../../assets/qualifications.json', () => ({ + qualifications: [ + { + label: 'isp_invoice', + purpose: 'invoice', + sourceCategory: 'telecom', + sourceSubCategory: 'internet', + subjects: ['subscription'] + }, + { + label: 'national_id_card', + purpose: 'attestation', + sourceCategory: 'gov', + sourceSubCategory: 'civil_registration', + subjects: ['identity'] + }, + { + label: 'health_invoice', + purpose: 'invoice', + sourceCategory: 'health' + }, + { + label: 'other_identity_document', + purpose: 'attestation', + subjects: ['identity'] + }, + { + label: 'dummy_empty' + } + ], + purposeKnownValues: ['attestation', 'invoice'], + sourceCategoryKnownValues: ['telecom', 'health', 'gov'], + sourceSubCategoryKnownValues: ['civil_registration', 'internet'], + subjectsKnownValues: ['identity', 'subscription'] +})) + describe('document qualification', () => { beforeEach(() => { jest.spyOn(logger, 'warn').mockImplementation(() => jest.fn()) @@ -133,6 +169,17 @@ describe('qualifications items', () => { }) }) + it('should not have undefined attributes', () => { + const qualification = Qualification.getByLabel('dummy_empty') + expect(Object.hasOwn(qualification, 'purpose')).toBe(false) + expect(Object.hasOwn(qualification, 'sourceCategory')).toBe(false) + expect(Object.hasOwn(qualification, 'sourceSubCategory')).toBe(false) + expect(Object.hasOwn(qualification, 'subjects')).toBe(false) + Object.keys(qualification).forEach(key => { + expect(qualification[key]).toBeDefined() + }) + }) + it('should define authorized attributes', () => { qualificationModel.qualifications.forEach(q => { if (q.purpose) {