Skip to content

Commit

Permalink
fix: typo in typologie column name
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-gavanier committed Jul 3, 2023
1 parent 2a580c1 commit 99e9a1f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"presentation_detail": {
"colonne": "description"
},
"typologies": [
"typologie": [
{
"cible": "TIERS_LIEUX"
}
Expand Down
2 changes: 1 addition & 1 deletion assets/input/hinaura/hinaura.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"pivot": {
"colonne": "bf_siret"
},
"typologies": [
"typologie": [
{
"colonnes": ["checkboxListeTypelieu"],
"termes": ["3", "4"],
Expand Down
22 changes: 19 additions & 3 deletions src/transformer/fields/typologies/typologies.field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('typologie field', (): void => {

it('should always get RFS as typologie', (): void => {
const matching: LieuxMediationNumeriqueMatching = {
typologies: [{ cible: Typologie.RFS }]
typologie: [{ cible: Typologie.RFS }]
} as LieuxMediationNumeriqueMatching;

const source: DataSource = {};
Expand All @@ -32,7 +32,7 @@ describe('typologie field', (): void => {
it('should always get RFS as typologie even if name could match something else', (): void => {
const matching: LieuxMediationNumeriqueMatching = {
nom: { colonne: 'name' },
typologies: [{ cible: Typologie.RFS }]
typologie: [{ cible: Typologie.RFS }]
} as LieuxMediationNumeriqueMatching;

const source: DataSource = {
Expand All @@ -45,7 +45,7 @@ describe('typologie field', (): void => {

it('should always get TIERS_LIEUX as typologie', (): void => {
const matching: LieuxMediationNumeriqueMatching = {
typologies: [{ cible: Typologie.TIERS_LIEUX }]
typologie: [{ cible: Typologie.TIERS_LIEUX }]
} as LieuxMediationNumeriqueMatching;

const source: DataSource = {};
Expand Down Expand Up @@ -1182,4 +1182,20 @@ describe('typologie field', (): void => {

expect(typologie).toBe(Typologie.MDS);
});

it('should get TIERS_LIEUX when this typologie is already present', (): void => {
const source: DataSource = {
nom: 'Holywood Atelier Bois Partagé',
typologie: 'TIERS_LIEUX'
};

const matching: LieuxMediationNumeriqueMatching = {
nom: { colonne: 'nom' },
typologie: [{ colonnes: ['typologie'], termes: ['TIERS_LIEUX'], cible: Typologie.TIERS_LIEUX }]
} as LieuxMediationNumeriqueMatching;

const [typologie]: Typologies = processTypologies(source, matching);

expect(typologie).toBe(Typologie.TIERS_LIEUX);
});
});
4 changes: 2 additions & 2 deletions src/transformer/fields/typologies/typologies.field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ const inferTypologies = (source: DataSource, matching: LieuxMediationNumeriqueMa
: TYPOLOGIE_MATCHERS.reduce(toTypologieMatchingName(source, matching), Typologies([]));

export const processTypologies = (source: DataSource, matching: LieuxMediationNumeriqueMatching): Typologies =>
matching.typologies?.at(0)?.cible == null
matching.typologie?.at(0)?.cible == null
? inferTypologies(source, matching)
: Typologies(Array.from(new Set(matching.typologies.reduce(appendTypologies(source), []))));
: Typologies(Array.from(new Set(matching.typologie.reduce(appendTypologies(source), []))));
2 changes: 1 addition & 1 deletion src/transformer/fields/typologies/typologies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('typologies field', (): void => {
it('should get BIB typologie for Médiathèque', (): void => {
const matching: LieuxMediationNumeriqueMatching = {
nom: { colonne: 'name' },
typologies: [{ colonnes: ['checkboxListeTypelieu'], termes: ['5'], cible: Typologie.BIB }]
typologie: [{ colonnes: ['checkboxListeTypelieu'], termes: ['5'], cible: Typologie.BIB }]
} as LieuxMediationNumeriqueMatching;

const typologies: Typologies = processTypologies({ checkboxListeTypelieu: '5' }, matching);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type LieuxMediationNumeriqueMatching = {
id?: Colonne;
nom: Colonne;
pivot?: Colonne;
typologies?: Choice<Typologie>[];
typologie?: Choice<Typologie>[];
code_postal: Colonne;
commune: Colonne;
adresse: Jonction & Partial<Colonne>;
Expand Down

0 comments on commit 99e9a1f

Please sign in to comment.