Add test for multiple rows

This commit is contained in:
Adria Navarro 2023-01-18 12:26:26 +00:00
parent e9361a5819
commit 8e73814675
1 changed files with 43 additions and 0 deletions

View File

@ -100,5 +100,48 @@ describe("row api", () => {
}), }),
]) ])
}) })
test("Given than no row exists, multiple rows can be persisted", async () => {
const tableName = faker.lorem.word()
const table = await config.createTable({
name: tableName,
schema: {
name: {
name: "name",
type: FieldType.STRING,
},
description: {
name: "description",
type: FieldType.STRING,
},
value: {
name: "value",
type: FieldType.NUMBER,
},
},
sourceId: postgresDatasource._id,
})
const numberOfRows = 10
const newRows = Array(numberOfRows).map(() => ({
name: faker.name.fullName(),
description: faker.lorem.paragraphs(),
value: +faker.random.numeric(),
}))
for (const newRow of newRows) {
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(numberOfRows)
expect(persistedRows).toEqual(expect.arrayContaining(newRows))
})
}) })
}) })