Clean configs

This commit is contained in:
Adria Navarro 2023-09-08 13:52:17 +02:00
parent 9e799c6b93
commit 5e2e43a7d7
1 changed files with 37 additions and 33 deletions

View File

@ -49,37 +49,39 @@ describe.each([
await config.init() await config.init()
}) })
beforeEach(async () => { const generateTableConfig: () => SaveTableRequest = () => ({
mocks.licenses.useCloudFree() name: generator.guid(),
let tableConfig: SaveTableRequest = { type: "table",
name: generator.guid(), primary: ["id"],
type: "table", schema: {
primary: ["id"], id: {
schema: { type: FieldType.AUTO,
id: { name: "id",
type: FieldType.AUTO, autocolumn: true,
name: "id", constraints: {
autocolumn: true, presence: true,
constraints: {
presence: true,
},
},
name: {
type: FieldType.STRING,
name: "name",
constraints: {
type: "string",
},
},
description: {
type: FieldType.STRING,
name: "description",
constraints: {
type: "string",
},
}, },
}, },
} name: {
type: FieldType.STRING,
name: "name",
constraints: {
type: "string",
},
},
description: {
type: FieldType.STRING,
name: "description",
constraints: {
type: "string",
},
},
},
})
beforeEach(async () => {
mocks.licenses.useCloudFree()
const tableConfig = generateTableConfig()
if (dsProvider) { if (dsProvider) {
datasource = await config.api.datasource.create( datasource = await config.api.datasource.create(
@ -93,6 +95,8 @@ describe.each([
} }
table = await config.api.table.create(tableConfig) table = await config.api.table.create(tableConfig)
config.table = table
config.datasource = datasource
row = basicRow(table._id!) row = basicRow(table._id!)
}) })
@ -130,8 +134,8 @@ describe.each([
expect(usage).toBe(expected) expect(usage).toBe(expected)
} }
const createRow = (row?: SaveRowRequest) => const createRow = (tableId = table._id!, row?: SaveRowRequest) =>
config.api.row.save(table._id!, row || basicRow(table._id!)) config.api.row.save(tableId, row || basicRow(table._id!))
describe("save, load, update", () => { describe("save, load, update", () => {
function getDefaultFields() { function getDefaultFields() {
@ -270,7 +274,7 @@ describe.each([
status: "new", status: "new",
} }
await createRow() await createRow()
await createRow(newRow) await createRow(table._id, newRow)
const queryUsage = await getQueryUsage() const queryUsage = await getQueryUsage()
const res = await request const res = await request
@ -552,7 +556,7 @@ describe.each([
describe("destroy", () => { describe("destroy", () => {
it("should be able to delete a row", async () => { it("should be able to delete a row", async () => {
const createdRow = await createRow(row) const createdRow = await createRow()
const rowUsage = await getRowUsage() const rowUsage = await getRowUsage()
const queryUsage = await getQueryUsage() const queryUsage = await getQueryUsage()