Skip to content

Commit

Permalink
Add test for nested entities
Browse files Browse the repository at this point in the history
  • Loading branch information
sgarner committed Aug 21, 2020
1 parent aaf5dd5 commit af710e6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/RelationMapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ describe('RelationMapper', () => {
owner {
id
name
address {
street
country {
id
name
}
}
}
store {
id
Expand All @@ -116,7 +123,7 @@ describe('RelationMapper', () => {
const resolveInfoHook = (info: GraphQLResolveInfo): void => {
const relations = new RelationMapper(connection).buildRelationListForQuery(Product, info);

expect([...relations]).toEqual(['owner', 'store', 'store.owner']);
expect([...relations]).toEqual(['owner', 'owner.address.country', 'store', 'store.owner']);
};
const result = await graphql(executableSchema, query, {}, { resolveInfoHook });

Expand All @@ -134,6 +141,13 @@ describe('RelationMapper', () => {
owner: {
id: expect.any(Number),
name: mockData.ownerA.name,
address: {
street: mockData.ownerA.address.street,
country: {
id: mockData.countryA.id,
name: mockData.countryA.name,
},
},
},
store: {
id: expect.any(Number),
Expand Down

0 comments on commit af710e6

Please sign in to comment.