Skip to content

Commit

Permalink
chore: filter getAllSurveyUnit method to filter mocked Data (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentC35 authored Jan 9, 2025
1 parent 68fdd47 commit 9587100
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/core/adapters/datastore/default.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Dexie, { type Table } from 'dexie'

import { mockPrefixIdSu } from '@/core/adapters/queenApi/mock'
import type { Paradata, SurveyUnit } from '@/core/model'
import type { DataStore } from '@/core/ports/DataStore'

Expand All @@ -21,7 +22,10 @@ export function createDataStore(params: {
return {
updateSurveyUnit: (surveyUnit) => db.surveyUnit.put(surveyUnit),
deleteSurveyUnit: (id) => db.surveyUnit.delete(id),
getAllSurveyUnits: () => db.surveyUnit.toArray(),
getAllSurveyUnits: () =>
db.surveyUnit
.filter(({ id }) => !id.startsWith(mockPrefixIdSu))
.toArray(),
getSurveyUnit: (id) => db.surveyUnit.get(id),
getAllParadatas: () => db.paradata.toArray(),
deleteParadata: (id) => db.paradata.delete(id),
Expand Down
4 changes: 3 additions & 1 deletion src/core/adapters/queenApi/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ export function createApiClient(): QueenApi {
}
}

export const mockPrefixIdSu = 'idSU'

function createSUMocked(props: {
idSu?: string
idCampaign?: string
}): SurveyUnit {
const { idSu = 'su1', idCampaign = 'campaign1' } = props
return {
id: `idSU:${idSu}`,
id: `${mockPrefixIdSu}:${idSu}`,
questionnaireId: `idCampaign${idCampaign}`,
personalization: [],
data: {
Expand Down

0 comments on commit 9587100

Please sign in to comment.