Skip to content

Commit

Permalink
test: add test for issue #2149
Browse files Browse the repository at this point in the history
Closes #2149
  • Loading branch information
B4nan committed Aug 27, 2021
1 parent 9092c6a commit 064a9a0
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/features/embeddables/GH2149.test.ts
@@ -0,0 +1,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');
});

});

0 comments on commit 064a9a0

Please sign in to comment.