Fix tests
This commit is contained in:
parent
a5142088d9
commit
45ddd46f4c
|
@ -137,17 +137,15 @@ describe.each([
|
||||||
const createRow = (tableId = table._id!, row?: SaveRowRequest) =>
|
const createRow = (tableId = table._id!, row?: SaveRowRequest) =>
|
||||||
config.api.row.save(tableId, row || basicRow(table._id!))
|
config.api.row.save(tableId, row || basicRow(table._id!))
|
||||||
|
|
||||||
describe("save, load, update", () => {
|
const defaultRowFields = isInternal
|
||||||
function getDefaultFields() {
|
? {
|
||||||
if (isInternal) {
|
type: "row",
|
||||||
return {
|
createdAt: timestamp,
|
||||||
type: "row",
|
updatedAt: timestamp,
|
||||||
createdAt: timestamp,
|
|
||||||
updatedAt: timestamp,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
: undefined
|
||||||
|
|
||||||
|
describe("save, load, update", () => {
|
||||||
it("returns a success message when the row is created", async () => {
|
it("returns a success message when the row is created", async () => {
|
||||||
const rowUsage = await getRowUsage()
|
const rowUsage = await getRowUsage()
|
||||||
const queryUsage = await getQueryUsage()
|
const queryUsage = await getQueryUsage()
|
||||||
|
@ -262,7 +260,7 @@ describe.each([
|
||||||
_id: existing._id,
|
_id: existing._id,
|
||||||
_rev: existing._rev,
|
_rev: existing._rev,
|
||||||
id: existing.id,
|
id: existing.id,
|
||||||
...getDefaultFields(),
|
...defaultRowFields,
|
||||||
})
|
})
|
||||||
await assertQueryUsage(queryUsage + 1)
|
await assertQueryUsage(queryUsage + 1)
|
||||||
})
|
})
|
||||||
|
@ -835,7 +833,7 @@ describe.each([
|
||||||
it("should allow enriching attachment rows", async () => {
|
it("should allow enriching attachment rows", async () => {
|
||||||
const table = await config.createAttachmentTable()
|
const table = await config.createAttachmentTable()
|
||||||
const attachmentId = `${structures.uuid()}.csv`
|
const attachmentId = `${structures.uuid()}.csv`
|
||||||
const row = await config.createRow({
|
const row = await createRow(table._id, {
|
||||||
name: "test",
|
name: "test",
|
||||||
description: "test",
|
description: "test",
|
||||||
attachment: [
|
attachment: [
|
||||||
|
@ -906,15 +904,24 @@ describe.each([
|
||||||
function userTable(): Table {
|
function userTable(): Table {
|
||||||
return {
|
return {
|
||||||
name: "user",
|
name: "user",
|
||||||
type: "user",
|
type: "table",
|
||||||
|
primary: ["id"],
|
||||||
schema: {
|
schema: {
|
||||||
|
id: {
|
||||||
|
type: FieldType.AUTO,
|
||||||
|
name: "id",
|
||||||
|
autocolumn: true,
|
||||||
|
constraints: {
|
||||||
|
presence: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
name: {
|
name: {
|
||||||
type: FieldType.STRING,
|
type: FieldType.STRING,
|
||||||
name: "name",
|
name: "name",
|
||||||
},
|
},
|
||||||
surname: {
|
surname: {
|
||||||
type: FieldType.STRING,
|
type: FieldType.STRING,
|
||||||
name: "name",
|
name: "surname",
|
||||||
},
|
},
|
||||||
age: {
|
age: {
|
||||||
type: FieldType.NUMBER,
|
type: FieldType.NUMBER,
|
||||||
|
@ -965,11 +972,10 @@ describe.each([
|
||||||
surname: data.surname,
|
surname: data.surname,
|
||||||
address: data.address,
|
address: data.address,
|
||||||
tableId: config.table!._id,
|
tableId: config.table!._id,
|
||||||
type: "row",
|
_id: newRow._id,
|
||||||
_id: expect.any(String),
|
_rev: newRow._rev,
|
||||||
_rev: expect.any(String),
|
id: newRow.id,
|
||||||
createdAt: expect.any(String),
|
...defaultRowFields,
|
||||||
updatedAt: expect.any(String),
|
|
||||||
})
|
})
|
||||||
expect(row.body._viewId).toBeUndefined()
|
expect(row.body._viewId).toBeUndefined()
|
||||||
expect(row.body.age).toBeUndefined()
|
expect(row.body.age).toBeUndefined()
|
||||||
|
@ -1006,13 +1012,12 @@ describe.each([
|
||||||
const row = await config.api.row.get(tableId, newRow._id!)
|
const row = await config.api.row.get(tableId, newRow._id!)
|
||||||
expect(row.body).toEqual({
|
expect(row.body).toEqual({
|
||||||
...newRow,
|
...newRow,
|
||||||
type: "row",
|
|
||||||
name: newData.name,
|
name: newData.name,
|
||||||
address: newData.address,
|
address: newData.address,
|
||||||
_id: expect.any(String),
|
_id: newRow._id,
|
||||||
_rev: expect.any(String),
|
_rev: expect.any(String),
|
||||||
createdAt: expect.any(String),
|
id: newRow.id,
|
||||||
updatedAt: expect.any(String),
|
...defaultRowFields,
|
||||||
})
|
})
|
||||||
expect(row.body._viewId).toBeUndefined()
|
expect(row.body._viewId).toBeUndefined()
|
||||||
expect(row.body.age).toBeUndefined()
|
expect(row.body.age).toBeUndefined()
|
||||||
|
|
Loading…
Reference in New Issue