Add column rename test.
This commit is contained in:
parent
79fc826697
commit
ae1e2dd2f2
|
@ -10,6 +10,7 @@ import {
|
||||||
TableSourceType,
|
TableSourceType,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { GoogleSheetsMock } from "./utils/googlesheets"
|
import { GoogleSheetsMock } from "./utils/googlesheets"
|
||||||
|
import exp from "constants"
|
||||||
|
|
||||||
describe("Google Sheets Integration", () => {
|
describe("Google Sheets Integration", () => {
|
||||||
const config = new TestConfiguration()
|
const config = new TestConfiguration()
|
||||||
|
@ -299,5 +300,42 @@ describe("Google Sheets Integration", () => {
|
||||||
expect(mock.cell("A2")).toEqual("Test Contact Updated")
|
expect(mock.cell("A2")).toEqual("Test Contact Updated")
|
||||||
expect(mock.cell("B2")).toEqual("original description updated")
|
expect(mock.cell("B2")).toEqual("original description updated")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should be able to rename a column", async () => {
|
||||||
|
const row = await config.api.row.save(table._id!, {
|
||||||
|
name: "Test Contact",
|
||||||
|
description: "original description",
|
||||||
|
})
|
||||||
|
|
||||||
|
const { name, ...otherColumns } = table.schema
|
||||||
|
const renamedTable = await config.api.table.save({
|
||||||
|
...table,
|
||||||
|
schema: {
|
||||||
|
...otherColumns,
|
||||||
|
renamed: {
|
||||||
|
...table.schema.name,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
_rename: {
|
||||||
|
old: "name",
|
||||||
|
updated: "renamed",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(renamedTable.schema.name).not.toBeDefined()
|
||||||
|
expect(renamedTable.schema.renamed).toBeDefined()
|
||||||
|
|
||||||
|
expect(mock.cell("A1")).toEqual("renamed")
|
||||||
|
expect(mock.cell("B1")).toEqual("description")
|
||||||
|
expect(mock.cell("A2")).toEqual("Test Contact")
|
||||||
|
expect(mock.cell("B2")).toEqual("original description")
|
||||||
|
expect(mock.cell("A3")).toEqual(null)
|
||||||
|
expect(mock.cell("B3")).toEqual(null)
|
||||||
|
|
||||||
|
const renamedRow = await config.api.row.get(table._id!, row._id!)
|
||||||
|
expect(renamedRow.renamed).toEqual("Test Contact")
|
||||||
|
expect(renamedRow.description).toEqual("original description")
|
||||||
|
expect(renamedRow.name).not.toBeDefined()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue