forked from typeorm/typeorm
/
issue-5762.ts
39 lines (30 loc) · 1.26 KB
/
issue-5762.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
import "reflect-metadata";
import {expect} from "chai";
import {Connection} from "../../../src";
import {User} from "./entity/User";
import {createTestingConnections, reloadTestingDatabases, closeTestingConnections} from "../../utils/test-utils";
import { URL } from "url";
describe("github issues > #5762 `Using URL as a rich column type breaks", () => {
let connections: Connection[];
before(async () => {
connections = await createTestingConnections({
entities: [User],
schemaCreate: true,
dropSchema: true
});
});
beforeEach(() => reloadTestingDatabases(connections));
after(() => closeTestingConnections(connections));
it("should allow assigning URL as a field value", () =>
Promise.all(connections.map(async (connection) => {
const userRepository = connection.getRepository(User);
const url = new URL("https://typeorm.io");
const user = new User();
user.id = 1;
user.url = url;
const promise = userRepository.save(user);
return expect(promise).to.eventually.be.deep.equal(user)
.and.to.have.property("url").be.instanceOf(URL)
.and.to.have.nested.property("href").equal(url.href);
})));
});