-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,635 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './medewerkers.ts' | ||
export * from './medewerkers.types.ts' | ||
export * from './medewerkers.mock.ts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Medewerker } from './medewerkers' | ||
import { TMedewerker } from './medewerkers.types' | ||
|
||
export const mockMedewerkerData = (): TMedewerker[] => [ | ||
{ | ||
id: '15551d6f-44e3-43f3-a9d2-59e583c91eb0', | ||
voornaam: 'John', | ||
tussenvoegsel: 'de', | ||
achternaam: 'Doe', | ||
email: '[email protected]', | ||
}, | ||
] | ||
|
||
export const mockMedewerker = (data: TMedewerker[] = mockMedewerkerData()): TMedewerker[] => data.map(item => new Medewerker(item)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Medewerker } from './medewerkers' | ||
import { mockMedewerkerData } from './medewerkers.mock' | ||
|
||
describe('Medewerker Entity', () => { | ||
it('should create a Medewerker entity with full data', () => { | ||
const medewerker = new Medewerker(mockMedewerkerData()[0]) | ||
|
||
expect(medewerker).toBeInstanceOf(Medewerker) | ||
expect(medewerker).toEqual(mockMedewerkerData()[0]) | ||
expect(medewerker.validate().success).toBe(true) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { SafeParseReturnType, z } from 'zod' | ||
import { TMedewerker } from './medewerkers.types' | ||
|
||
export class Medewerker implements TMedewerker { | ||
|
||
public id: string | ||
public voornaam: string | ||
public tussenvoegsel: string | ||
public achternaam: string | ||
public email: string | ||
|
||
constructor(source: TMedewerker) { | ||
this.id = source.id || '' | ||
this.voornaam = source.voornaam || '' | ||
this.tussenvoegsel = source.tussenvoegsel || '' | ||
this.achternaam = source.achternaam || '' | ||
this.email = source.email || '' | ||
|
||
} | ||
|
||
public validate(): SafeParseReturnType<TMedewerker, unknown> { | ||
const schema = z.object({ | ||
id: z.string().optional(), | ||
voornaam: z.string().min(1), | ||
tussenvoegsel: z.string(), | ||
achternaam: z.string(), | ||
email: z.string().email(), | ||
}) | ||
|
||
return schema.safeParse(this) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type TMedewerker = { | ||
id: string; | ||
voornaam: string; | ||
tussenvoegsel: string; | ||
achternaam: string; | ||
email: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.