Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
zichongkao committed May 21, 2023
1 parent e51db9e commit 3fbd76e
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/__tests__/areas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,52 @@ describe('areas API', () => {
await inMemoryDB.close()
})

describe('mutations', () => {
it('updates sorting order and returns children in order', async () => {
const updateSortingOrderQuery = `
mutation ($input: [AreaSortingInput]) {
updateAreasSortingOrder(input: $input)
}
`
const updateResponse = await queryAPI({
query: updateSortingOrderQuery,
variables: { input: [
{ areaId: wa.metadata.area_id, leftRightIndex: 3 },
{ areaId: ca.metadata.area_id, leftRightIndex: 0 },
]},
userUuid
})

expect(updateResponse.statusCode).toBe(200)
const sortingOrderResult = updateResponse.body.data.updateAreasSortingOrder
expect(sortingOrderResult).toHaveLength(2)

const areaChildrenQuery = `
query area($input: ID) {
area(uuid: $input) {
children {
uuid
metadata {
leftRightIndex
}
}
}
}
`

const areaChildrenResponse = await queryAPI({
query: areaChildrenQuery,
variables: { input: usa.metadata.area_id },
userUuid
})

expect(areaChildrenResponse.statusCode).toBe(200)
const areaResult = areaChildrenResponse.body.data.area
expect(areaResult.children[0]).toMatchObject({uuid: muuidToString(ca.metadata.area_id), metadata: { leftRightIndex: 0 }})
expect(areaResult.children[1]).toMatchObject({uuid: muuidToString(wa.metadata.area_id), metadata: { leftRightIndex: 3 }})
})
})

describe('queries', () => {
const areaQuery = `
query area($input: ID) {
Expand Down

0 comments on commit 3fbd76e

Please sign in to comment.