-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.setup.ts
44 lines (38 loc) · 1.13 KB
/
jest.setup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import 'reflect-metadata';
export const MockGetService = jest.fn();
jest.mock('./src/service-provider', () => ({
...jest.requireActual('./src/service-provider') as Record<string, unknown>,
GetService: MockGetService
}));
import { Validators, Model, IModelOptions, PropertyModifier, Modifiers } from './src';
export interface IFoo {
foo?: string;
coerceDate?: Date;
}
export class Foo extends Model implements IFoo {
@Validators.required foo!: string;
@Modifiers([PropertyModifier.internal])
coerceBoolean!: boolean;
@Modifiers([PropertyModifier.internal])
coerceNumber!: number;
@Modifiers([PropertyModifier.internal])
coerceDate!: Date;
@Modifiers([PropertyModifier.internal])
@Modifiers([PropertyModifier.extended])
coerceString!: string;
constructor(props: IFoo, options?: IModelOptions) {
super(props, options);
}
}
export interface IBar {
foo?: IFoo;
bar?: string;
}
export class Bar extends Model implements IBar {
@Validators.required foo!: Foo
bar!: string;
constructor(props: IBar) {
super(props);
this.foo = new Foo(this.foo);
}
}