Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlr committed Jul 8, 2024
1 parent 9d2f4ac commit 00ece8c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
10 changes: 2 additions & 8 deletions server/tests/unit/deca.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { findPersons } from "../../src/modules/actions/persons.actions";
import {
buildDecaContract,
buildPeriodsToFetch,
NB_JOURS_MAX_PERIODE_FETCH,
shouldStopCallingDeca,
} from "../../src/modules/jobs/deca/hydrate-deca";
import { deepFlattenToObject } from "../../src/modules/jobs/deca/hydrate-deca-history";
Expand Down Expand Up @@ -248,18 +247,13 @@ describe("IMPORT DECA from API", () => {
await mongo.afterAll();
});

it("periods to fetch OK", () => {
const periods1 = buildPeriodsToFetch(new Date("2024-01-01"), new Date("2024-01-04"));
it("periods to fetch OK", async () => {
const periods1 = await buildPeriodsToFetch(new Date("2024-01-01"), new Date("2024-01-04"));
assert.deepEqual(periods1, [
{ dateDebut: "2024-01-01", dateFin: "2024-01-02" },
{ dateDebut: "2024-01-02", dateFin: "2024-01-03" },
{ dateDebut: "2024-01-03", dateFin: "2024-01-04" },
]);

const periods2 = buildPeriodsToFetch(new Date("2024-01-01"), new Date("2024-03-01"));
assert.deepEqual(periods2.length, NB_JOURS_MAX_PERIODE_FETCH);
assert.deepEqual(periods2[0], { dateDebut: "2024-01-01", dateFin: "2024-01-02" });
assert.deepEqual(periods2[NB_JOURS_MAX_PERIODE_FETCH - 1], { dateDebut: "2024-01-30", dateFin: "2024-01-31" });
});

it("building deca contract OK", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ exports[`zodToMongoSchema > should convert deca schema 1`] = `
},
"numero": {
"bsonType": [
"number",
"string",
"null",
],
"description": "Le numéro de l'adresse",
Expand All @@ -229,7 +229,7 @@ exports[`zodToMongoSchema > should convert deca schema 1`] = `
},
"derniere_classe": {
"bsonType": [
"string",
"number",
"null",
],
"description": "La dernière classe de l'apprenant",
Expand Down Expand Up @@ -268,7 +268,14 @@ exports[`zodToMongoSchema > should convert deca schema 1`] = `
],
},
"created_at": {
"bsonType": "date",
"anyOf": [
{
"bsonType": "date",
},
{
"bsonType": "null",
},
],
"description": "Date d'ajout en base de données",
},
"date_debut_contrat": {
Expand Down Expand Up @@ -484,6 +491,36 @@ exports[`zodToMongoSchema > should convert decaHistory schema 1`] = `
}
`;

exports[`zodToMongoSchema > should convert decaimportjobresult schema 1`] = `
{
"additionalProperties": false,
"bsonType": "object",
"properties": {
"_id": {
"bsonType": "objectId",
},
"created_at": {
"bsonType": "date",
"description": "Date d'ajout en base de données",
},
"has_completed": {
"bsonType": "bool",
"description": "true marque que l'import pour ce jour précis est complet. informatif uniquement. false ne sera jamais enregistré",
},
"import_date": {
"bsonType": "string",
"description": "La date d'un import deca au format yyyy-MM-dd",
},
},
"required": [
"_id",
"import_date",
"has_completed",
"created_at",
],
}
`;

exports[`zodToMongoSchema > should convert documentContents schema 1`] = `
{
"additionalProperties": false,
Expand Down

0 comments on commit 00ece8c

Please sign in to comment.