Skip to content

Commit

Permalink
fix: complex relation typeorm#1 test
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin-Dobell committed Jan 13, 2020
1 parent 3ed85ea commit 8686d7e
Showing 1 changed file with 16 additions and 47 deletions.
63 changes: 16 additions & 47 deletions test/functional/find-options/basic-usage/find-options-relations.ts
Expand Up @@ -3,7 +3,6 @@ import {Connection} from "../../../../src";
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../../utils/test-utils";
import {Post} from "./entity/Post";
import {prepareData} from "./find-options-test-utils";
import {PostgresDriver} from "../../../../src/driver/postgres/PostgresDriver";

describe("find options > relations", () => {

Expand Down Expand Up @@ -45,9 +44,6 @@ describe("find options > relations", () => {

it("complex relation #1", () => Promise.all(connections.map(async connection => {

if (connection.driver instanceof PostgresDriver) // in postgres ordering works a bit different that's why we decided to skip it
return;

await prepareData(connection.manager);

const posts = await connection.createQueryBuilder(Post, "post").setFindOptions({
Expand All @@ -71,52 +67,25 @@ describe("find options > relations", () => {
}
}
}).getMany();
posts.should.be.eql([
{
id: 3,
title: "Post #3",
text: "About post #3",
counters: {
likes: 1
},
author: {
id: 2,
age: 52,
photos: []
}
},
{
id: 1,
title: "Post #1",
text: "About post #1",
counters: {
likes: 1
},
author: {
id: 1,
age: 25,
photos: [
{ id: 2, filename: "chain.jpg", description: "Me and chain" },
{ id: 1, filename: "saw.jpg", description: "Me and saw" }
]
}

posts.length.should.be.eql(3);
posts[0].should.be.eql({
id: 3,
title: "Post #3",
text: "About post #3",
counters: {
likes: 1
},
{
author: {
id: 2,
title: "Post #2",
text: "About post #2",
counters: {
likes: 2
},
author: {
id: 1,
age: 25,
photos: [
{ id: 2, filename: "chain.jpg", description: "Me and chain" },
{ id: 1, filename: "saw.jpg", description: "Me and saw" }
]
}
age: 52,
photos: []
}
});
posts[1].author.should.be.eql(posts[2].author);
posts[1].author.photos.should.be.eql([
{ id: 2, filename: "chain.jpg", description: "Me and chain" },
{ id: 1, filename: "saw.jpg", description: "Me and saw" }
]);

})));
Expand Down

0 comments on commit 8686d7e

Please sign in to comment.