Migrate RowAPI.save

This commit is contained in:
Sam Rose 2024-03-01 16:38:31 +00:00
parent d5c6ab8648
commit a639ba91d3
No known key found for this signature in database
2 changed files with 6 additions and 15 deletions

View File

@ -1486,7 +1486,7 @@ describe.each([
email: "joe@joe.com",
roles: {},
},
{ expectStatus: 400 }
{ status: 400 }
)
expect(response.message).toBe("Cannot create new user entry.")
})

View File

@ -35,21 +35,12 @@ export class RowAPI extends TestAPI {
save = async (
tableId: string,
row: SaveRowRequest,
{ expectStatus } = { expectStatus: 200 }
expectations?: Expectations
): Promise<Row> => {
const resp = await this.request
.post(`/api/${tableId}/rows`)
.send(row)
.set(this.config.defaultHeaders())
.expect("Content-Type", /json/)
if (resp.status !== expectStatus) {
throw new Error(
`Expected status ${expectStatus} but got ${
resp.status
}, body: ${JSON.stringify(resp.body)}`
)
}
return resp.body as Row
return await this._post<Row>(`/api/${tableId}/rows`, {
body: row,
expectations,
})
}
validate = async (