Co-authored-by: Jason Rasmussen <jason@rasm.me> Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
36 lines
861 B
TypeScript
36 lines
861 B
TypeScript
import { PersonLike, PersonRow } from 'test/factories/types.js';
|
|
import { newDate, newUuid, newUuidV7 } from 'test/small.factory.js';
|
|
|
|
export class PersonFactory {
|
|
private constructor(private readonly value: PersonRow) {}
|
|
|
|
static create(dto: PersonLike = {}) {
|
|
return PersonFactory.from(dto).build();
|
|
}
|
|
|
|
static from(dto: PersonLike = {}) {
|
|
return new PersonFactory({
|
|
birthDate: null,
|
|
color: null,
|
|
createdAt: newDate(),
|
|
faceAssetId: null,
|
|
personGroupId: newUuid(),
|
|
isFavorite: false,
|
|
isHidden: false,
|
|
name: 'person',
|
|
otherPeople: [],
|
|
sharedBy: [],
|
|
sharedWith: [],
|
|
ownerId: newUuid(),
|
|
thumbnailPath: '/data/thumbs/person-thumbnail.jpg',
|
|
updatedAt: newDate(),
|
|
updateId: newUuidV7(),
|
|
...dto,
|
|
});
|
|
}
|
|
|
|
build() {
|
|
return { ...this.value };
|
|
}
|
|
}
|