Implement test

This commit is contained in:
Adria Navarro 2023-01-17 17:39:59 +00:00
parent 89e0610600
commit cc930097a8
2 changed files with 12 additions and 3 deletions

View File

@ -41,7 +41,7 @@ describe("row api", () => {
describe("create a row", () => {
test("Given than no row exists, adding a new rows persists it", async () => {
const tableName = faker.lorem.word()
let table = await config.createTable({
const table = await config.createTable({
name: tableName,
schema: {
name: {
@ -62,12 +62,21 @@ describe("row api", () => {
const newRow = {
name: faker.name.fullName(),
description: faker.lorem.paragraphs(),
value: faker.random.numeric(),
value: +faker.random.numeric(),
}
const res = await makeRequest("post", `/tables/${table._id}/rows`, newRow)
expect(res.status).toBe(200)
const persistedRows = await config.getRows(table._id!)
expect(persistedRows).toHaveLength(1)
expect(persistedRows).toEqual([
expect.objectContaining({
...res.body.data,
...newRow,
}),
])
})
})
})

View File

@ -413,7 +413,7 @@ class TestConfiguration {
// TABLE
async updateTable(config?: any) {
async updateTable(config?: any): Promise<Table> {
config = config || basicTable()
this.table = await this._req(config, null, controllers.table.save)
return this.table