From cc930097a83183d1da4c1777ebf0adc3e64996e0 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 17 Jan 2023 17:39:59 +0000 Subject: [PATCH] Implement test --- packages/server/src/integration-test/row.spec.ts | 13 +++++++++++-- .../server/src/tests/utilities/TestConfiguration.ts | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/server/src/integration-test/row.spec.ts b/packages/server/src/integration-test/row.spec.ts index 3c65152871..ece0090a5a 100644 --- a/packages/server/src/integration-test/row.spec.ts +++ b/packages/server/src/integration-test/row.spec.ts @@ -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, + }), + ]) }) }) }) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index b9d4470c88..ce4fa287a0 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -413,7 +413,7 @@ class TestConfiguration { // TABLE - async updateTable(config?: any) { + async updateTable(config?: any): Promise { config = config || basicTable() this.table = await this._req(config, null, controllers.table.save) return this.table