Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 67cf4c3

Browse files
committed
added test for typeorm#7541
1 parent a3a6e06 commit 67cf4c3

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {Column, Entity, PrimaryGeneratedColumn} from "../../../../src";
2+
3+
enum StandardSetType {
4+
AcademicStandard = "AcademicStandard",
5+
FoundationalKnowledge = "FoundationalKnowledge",
6+
AchievementDescriptor = "AchievementDescriptor",
7+
}
8+
9+
@Entity()
10+
export class TestEntity {
11+
@PrimaryGeneratedColumn()
12+
ud: number
13+
14+
@Column("enum", { enum: StandardSetType, name: "type" })
15+
type: StandardSetType;
16+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import "reflect-metadata";
2+
import {Connection} from "../../../src";
3+
import {closeTestingConnections, createTestingConnections} from "../../utils/test-utils";
4+
import {TestEntity} from "./entity/Test";
5+
6+
describe("github issues > #7541 Column of type `enum` throws missing properties error", () => {
7+
let connections: Connection[];
8+
before(async () => connections = await createTestingConnections({
9+
enabledDrivers: ["postgres"],
10+
schemaCreate: false,
11+
dropSchema: true,
12+
entities: [TestEntity],
13+
}));
14+
after(() => closeTestingConnections(connections));
15+
16+
it("should recognize model changes", () => Promise.all(connections.map(async connection => {
17+
const sqlInMemory = await connection.driver.createSchemaBuilder().log();
18+
sqlInMemory.upQueries.length.should.be.greaterThan(0);
19+
sqlInMemory.downQueries.length.should.be.greaterThan(0);
20+
})));
21+
22+
it("should not generate queries when no model changes", () => Promise.all(connections.map(async connection => {
23+
await connection.driver.createSchemaBuilder().build();
24+
const sqlInMemory = await connection.driver.createSchemaBuilder().log();
25+
sqlInMemory.upQueries.length.should.be.equal(0);
26+
sqlInMemory.downQueries.length.should.be.equal(0);
27+
})));
28+
});

0 commit comments

Comments
 (0)