Skip to content

Commit

Permalink
Merge pull request #880 from betagouv/main
Browse files Browse the repository at this point in the history
MEP [TRELLO-2516] Add image & path to categories API (#879)
  • Loading branch information
charlescd authored Aug 23, 2024
2 parents 4935baa + c3b52f4 commit 95a818e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mobile-tools/src/app.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import request from 'supertest'
import {app} from './app'
import {Category} from './services/categories.service'
import {Config} from './config/config'

describe('Test the actus path', () => {
test('It should response the GET method', async () => {
Expand All @@ -22,6 +23,8 @@ describe('Test the categories path', () => {
category: 'AchatMagasin',
description: 'Prix, promotion, qualité, poids, garantie, …',
id: '10',
path: 'achat-magasin',
img: `${Config.websiteUrl}/image/pictos/category-store.png`,
})
})
test('It should return french categories', async () => {
Expand All @@ -31,6 +34,8 @@ describe('Test the categories path', () => {
category: 'AchatMagasin',
description: 'Prix, promotion, qualité, poids, garantie, …',
id: '10',
path: 'achat-magasin',
img: `${Config.websiteUrl}/image/pictos/category-store.png`,
})
})
test('It should return english categories', async () => {
Expand All @@ -40,6 +45,8 @@ describe('Test the categories path', () => {
category: 'AchatMagasin',
description: 'Price, promotion, quality, weight, warranty, etc.',
id: '10',
path: 'achat-magasin',
img: `${Config.websiteUrl}/image/pictos/category-store.png`,
})
})
})
1 change: 1 addition & 0 deletions mobile-tools/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export const Config = {
oneSignalEnablePush: process.env.ONE_SIGNAL_ENABLE_PUSH === 'true' ?? false,
oneSignalAppId: process.env.ONE_SIGNAL_APP_ID ?? '',
oneSignaleApiKey: process.env.ONE_SIGNAL_API_KEY ?? '',
websiteUrl: process.env.WEBSITE_URL ?? '',
}
7 changes: 7 additions & 0 deletions mobile-tools/src/services/categories.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import fs from 'fs'
import {Config} from '../config/config.js'

export interface Category {
category: string
description: string
id: string
path: string
img: string
}

const anomaliesFr = JSON.parse(fs.readFileSync('../shared/anomalies/json/anomalies_fr.json', 'utf-8'))
Expand All @@ -17,6 +20,8 @@ const categoriesFr: Category[] = anomaliesFr.map((anomaly: any) => {
category: anomaly.category,
description: anomaly.description,
id: anomaly.id,
path: anomaly.path,
img: `${Config.websiteUrl}/image/pictos/${anomaly.img}.png`,
}
})

Expand All @@ -25,6 +30,8 @@ const categoriesEn: Category[] = anomaliesEn.map((anomaly: any) => {
category: anomaly.category,
description: anomaly.description,
id: anomaly.id,
path: anomaly.path,
img: `${Config.websiteUrl}/image/pictos/${anomaly.img}.png`,
}
})

Expand Down

0 comments on commit 95a818e

Please sign in to comment.