Skip to content

Commit

Permalink
feat(caasmapper): add lifespan property to section (#187)
Browse files Browse the repository at this point in the history
* feat(caasmapper): add section lifespan property
  • Loading branch information
deangite committed Oct 4, 2023
1 parent 75cb30a commit 591dda7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/modules/CaaSMapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,20 @@ describe('CaaSMapper', () => {
displayed: true,
})
})
it('should map lifespan property', async () => {
const mapper = new CaaSMapper(createApi(), 'de', {}, createLogger())
const section: CaaSApi_Section = createSection()
const lifespan = {
start: '2022-09-25T12:43:56.000Z',
end: '2024-09-24T12:49:59.000Z',
}
section.lifespan = lifespan
const res = await mapper.mapSection(section, createPath())
expect(res.lifespan).toEqual({
start: new Date(lifespan.start),
end: new Date(lifespan.end),
})
})
})

describe('mapBodyContent', () => {
Expand Down
6 changes: 6 additions & 0 deletions src/modules/CaaSMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,12 @@ export class CaaSMapper {
remoteProjectId
),
displayed: section.displayed,
...(section.lifespan && {
lifespan: {
start: new Date(section.lifespan.start),
...(section.lifespan.end && { end: new Date(section.lifespan.end) }),
},
}),
children: [],
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ export interface MasterLocale {
identifier: string
}

export interface CaaSApi_Lifespan {
start: string
end?: string
}

export interface Lifespan {
start: Date
end?: Date
}

export interface CaaSApi_Template {
fsType: 'PageTemplate' | 'SectionTemplate' | 'LinkTemplate'
name: string
Expand Down Expand Up @@ -388,6 +398,7 @@ export interface CaaSApi_Section {
template: CaaSApi_Template
formData: CaaSApi_DataEntries
displayed?: boolean
lifespan?: CaaSApi_Lifespan
}

export interface CaaSApi_SectionReference {
Expand All @@ -398,6 +409,7 @@ export interface CaaSApi_SectionReference {
template: CaaSApi_Template
formData: CaaSApi_DataEntries
displayed?: boolean
lifespan?: CaaSApi_Lifespan
}

export interface CaaSApi_Body {
Expand Down Expand Up @@ -668,6 +680,7 @@ export interface Section {
sectionType: string
data: DataEntries
displayed?: boolean
lifespan?: Lifespan
children: Section[]
}

Expand Down

0 comments on commit 591dda7

Please sign in to comment.