Migrate RowAPI.save
This commit is contained in:
parent
d5c6ab8648
commit
a639ba91d3
|
@ -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.")
|
||||||
})
|
})
|
||||||
|
|
|
@ -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 (
|
||||||
|
|
Loading…
Reference in New Issue