Skip to content

Commit 3fbd76e

Browse files
committed
Add integration test
1 parent e51db9e commit 3fbd76e

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/__tests__/areas.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,52 @@ describe('areas API', () => {
4545
await inMemoryDB.close()
4646
})
4747

48+
describe('mutations', () => {
49+
it('updates sorting order and returns children in order', async () => {
50+
const updateSortingOrderQuery = `
51+
mutation ($input: [AreaSortingInput]) {
52+
updateAreasSortingOrder(input: $input)
53+
}
54+
`
55+
const updateResponse = await queryAPI({
56+
query: updateSortingOrderQuery,
57+
variables: { input: [
58+
{ areaId: wa.metadata.area_id, leftRightIndex: 3 },
59+
{ areaId: ca.metadata.area_id, leftRightIndex: 0 },
60+
]},
61+
userUuid
62+
})
63+
64+
expect(updateResponse.statusCode).toBe(200)
65+
const sortingOrderResult = updateResponse.body.data.updateAreasSortingOrder
66+
expect(sortingOrderResult).toHaveLength(2)
67+
68+
const areaChildrenQuery = `
69+
query area($input: ID) {
70+
area(uuid: $input) {
71+
children {
72+
uuid
73+
metadata {
74+
leftRightIndex
75+
}
76+
}
77+
}
78+
}
79+
`
80+
81+
const areaChildrenResponse = await queryAPI({
82+
query: areaChildrenQuery,
83+
variables: { input: usa.metadata.area_id },
84+
userUuid
85+
})
86+
87+
expect(areaChildrenResponse.statusCode).toBe(200)
88+
const areaResult = areaChildrenResponse.body.data.area
89+
expect(areaResult.children[0]).toMatchObject({uuid: muuidToString(ca.metadata.area_id), metadata: { leftRightIndex: 0 }})
90+
expect(areaResult.children[1]).toMatchObject({uuid: muuidToString(wa.metadata.area_id), metadata: { leftRightIndex: 3 }})
91+
})
92+
})
93+
4894
describe('queries', () => {
4995
const areaQuery = `
5096
query area($input: ID) {

0 commit comments

Comments
 (0)