Add test for string imports into array fields
This commit is contained in:
parent
e0511f8b07
commit
a4caad86d1
|
@ -1,4 +1,9 @@
|
|||
import { AIOperationEnum, AutoFieldSubType, FieldType } from "@budibase/types"
|
||||
import {
|
||||
AIOperationEnum,
|
||||
AutoFieldSubType,
|
||||
FieldType,
|
||||
JsonFieldSubType,
|
||||
} from "@budibase/types"
|
||||
import TestConfiguration from "../../../../tests/utilities/TestConfiguration"
|
||||
import { importToRows } from "../utils"
|
||||
|
||||
|
@ -152,5 +157,33 @@ describe("utils", () => {
|
|||
])
|
||||
})
|
||||
})
|
||||
|
||||
it("coerces strings into arrays for array fields", async () => {
|
||||
await config.doInContext(config.appId, async () => {
|
||||
const table = await config.createTable({
|
||||
name: "table",
|
||||
type: "table",
|
||||
schema: {
|
||||
colours: {
|
||||
name: "colours",
|
||||
type: FieldType.ARRAY,
|
||||
constraints: {
|
||||
type: JsonFieldSubType.ARRAY,
|
||||
inclusion: ["red"],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const data = [{ colours: "red" }]
|
||||
|
||||
const result = await importToRows(data, table, config.user?._id)
|
||||
expect(result).toEqual([
|
||||
expect.objectContaining({
|
||||
colours: ["red"],
|
||||
}),
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue