tests for infractructure, domain entities and create authentication service

This commit is contained in:
sbriat
2023-07-06 17:38:57 +02:00
parent 470a93879e
commit b23f8f9ade
7 changed files with 296 additions and 3 deletions

View File

@@ -1,11 +1,13 @@
import { AggregateID, AggregateRoot } from '@mobicoop/ddd-library';
import { UsernameProps } from './username.types';
import { CreateUsernameProps, UsernameProps } from './username.types';
import { UsernameAddedDomainEvent } from './events/username-added.domain-event';
export class UsernameEntity extends AggregateRoot<UsernameProps> {
protected readonly _id: AggregateID;
static create = async (create: UsernameProps): Promise<UsernameEntity> => {
static create = async (
create: CreateUsernameProps,
): Promise<UsernameEntity> => {
const props: UsernameProps = { ...create };
const username = new UsernameEntity({
id: props.name,

View File

@@ -1,10 +1,15 @@
// All properties that a Username has
export interface UsernameProps {
name: string;
userId?: string;
type: Type;
}
export interface CreateUsernameProps {
name: string;
userId: string;
type: Type;
}
export enum Type {
EMAIL = 'EMAIL',
PHONE = 'PHONE',