/
GH2149.test.ts
57 lines (40 loc) · 1.01 KB
/
GH2149.test.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
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Embeddable, Embedded, Entity, MikroORM, PrimaryKey, Property } from '@mikro-orm/core';
@Embeddable()
export class LoopOptions {
@Property()
enabled = false;
@Property()
type = 'a';
}
@Embeddable()
export class Options {
@Embedded(() => LoopOptions, { object: true })
loop = new LoopOptions();
}
@Entity()
export class PlayerEntity {
@PrimaryKey()
id!: number;
@Embedded(() => Options, { object: true })
options = new Options();
}
describe('GH issue 2149', () => {
let orm: MikroORM;
beforeAll(async () => {
orm = await MikroORM.init({
entities: [PlayerEntity, Options, LoopOptions],
dbName: 'test',
type: 'mongo',
}, false);
});
afterAll(async () => {
await orm.close();
});
test(`GH issue 1912`, async () => {
const e = new PlayerEntity();
expect(e.options).toBeInstanceOf(Options);
expect(e.options.loop).toBeInstanceOf(LoopOptions);
expect(e.options.loop.enabled).toBe(false);
expect(e.options.loop.type).toBe('a');
});
});