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", email: "joe@joe.com",
roles: {}, roles: {},
}, },
{ expectStatus: 400 } { status: 400 }
) )
expect(response.message).toBe("Cannot create new user entry.") expect(response.message).toBe("Cannot create new user entry.")
}) })

View File

@ -35,21 +35,12 @@ export class RowAPI extends TestAPI {
save = async ( save = async (
tableId: string, tableId: string,
row: SaveRowRequest, row: SaveRowRequest,
{ expectStatus } = { expectStatus: 200 } expectations?: Expectations
): Promise<Row> => { ): Promise<Row> => {
const resp = await this.request return await this._post<Row>(`/api/${tableId}/rows`, {
.post(`/api/${tableId}/rows`) body: row,
.send(row) expectations,
.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
} }
validate = async ( validate = async (