From 8e73814675c1cb26e7ae94cee66e5927560ddc84 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 18 Jan 2023 12:26:26 +0000 Subject: [PATCH] Add test for multiple rows --- .../server/src/integration-test/row.spec.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/packages/server/src/integration-test/row.spec.ts b/packages/server/src/integration-test/row.spec.ts index 44ca5a3d4d..4863047265 100644 --- a/packages/server/src/integration-test/row.spec.ts +++ b/packages/server/src/integration-test/row.spec.ts @@ -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)) + }) }) })