Skip to content

Commit

Permalink
fix(api): joi verification for certification centers get
Browse files Browse the repository at this point in the history
  • Loading branch information
machestla authored Jul 9, 2024
1 parent 0a64635 commit de59774
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
14 changes: 11 additions & 3 deletions api/lib/application/certification-centers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Joi from 'joi';

import { securityPreHandlers } from '../../../src/shared/application/security-pre-handlers.js';
import { identifiersType } from '../../../src/shared/domain/types/identifiers-type.js';
import { identifiersType, optionalIdentifiersType } from '../../../src/shared/domain/types/identifiers-type.js';
import { certificationCenterController } from './certification-center-controller.js';

const register = async function (server) {
Expand Down Expand Up @@ -49,8 +49,16 @@ const register = async function (server) {
],
validate: {
query: Joi.object({
page: Joi.object().default({}),
filter: Joi.object().default({}),
page: Joi.object({
number: Joi.number().integer(),
size: Joi.number().integer(),
}).default({}),
filter: Joi.object({
id: optionalIdentifiersType.certificationCenterId,
name: Joi.string().trim().empty('').allow(null).optional(),
type: Joi.string().trim().empty('').allow(null).optional(),
externalId: Joi.string().trim().empty('').allow(null).optional(),
}).default({}),
}),
},
notes: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ describe('Acceptance | Route | Certification Centers', function () {
server = await createServer();
});

describe('GET /api/admin/certification-centers', function () {
it('should return an HTTP code 200 and a list of certification centers', async function () {
// given
const adminMember = await insertUserWithRoleSuperAdmin();
databaseBuilder.factory.buildCertificationCenter();

await databaseBuilder.commit();

//when
const { result, statusCode } = await server.inject({
headers: {
authorization: generateValidRequestAuthorizationHeader(adminMember.id),
},
method: 'GET',
url: `/api/admin/certification-centers`,
});

expect(statusCode).to.equal(200);
expect(result.data.length).to.equal(1);
});
});

describe('PATCH /api/admin/certification-centers/{id}', function () {
context('when an admin member updates a certification center information', function () {
it('it should return an HTTP code 200 with the updated data', async function () {
Expand Down

0 comments on commit de59774

Please sign in to comment.