Skip to content

Commit

Permalink
add findspotFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Nov 3, 2023
1 parent 8c6e44d commit ea9c1c4
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/test-support/fragment-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import { periodModifiers, periods } from 'common/period'
import { ExternalNumbers } from 'fragmentarium/domain/FragmentDtos'
import { MesopotamianDate } from 'fragmentarium/domain/Date'
import { mesopotamianDateFactory } from './date-fixtures'
import { Archaeology, excavationSites } from 'fragmentarium/domain/archaeology'
import {
Archaeology,
Findspot,
excavationSites,
} from 'fragmentarium/domain/archaeology'

const defaultChance = new Chance()

Expand Down Expand Up @@ -166,13 +170,37 @@ export const externalNumbersFactory = Factory.define<ExternalNumbers>(
}
)

export const findspotFactory = Factory.define<Findspot>(
({ transientParams, sequence }) => {
const chance = transientParams.chance ?? defaultChance

return new Findspot(
sequence,
chance.pickone(Object.values(excavationSites)),
chance.word(),
chance.word(),
chance.pickone(['RESIDENTIAL', 'TEMPLE', 'UNKNOWN']),
chance.word(),
{ start: new Date('01-01-200'), end: null, notes: 'a date test note' },
[],
chance.word(),
chance.word(),
chance.bool(),
chance.sentence()
)
}
)

export const archaeologyFactory = Factory.define<Archaeology>(
({ transientParams, sequence }) => {
const chance = transientParams.chance ?? defaultChance
const findspot = findspotFactory.build()
return {
excavationNumber: `${chance.word()}.${sequence}`,
site: chance.pickone(Object.values(excavationSites)),
isRegularExcavation: chance.bool(),
findspot: findspot,
findspotId: findspot.id,
}
}
)
Expand Down

0 comments on commit ea9c1c4

Please sign in to comment.