Remove unnecessary row mappings. Updated input processing tests to accommodate clearing BB_REFERENCE types by defaulting to an empty array

This commit is contained in:
Dean 2024-06-28 10:42:58 +01:00
parent fdbf1b3469
commit 7d274e5a84
2 changed files with 13 additions and 11 deletions

View File

@ -57,13 +57,6 @@ export const TYPE_TRANSFORM_MAP: any = {
[undefined]: undefined, [undefined]: undefined,
parse: parseArrayString, parse: parseArrayString,
}, },
[FieldType.BB_REFERENCE_SINGLE]: {
"": null,
//@ts-ignore
[null]: null,
//@ts-ignore
[undefined]: undefined,
},
[FieldType.STRING]: { [FieldType.STRING]: {
"": null, "": null,
//@ts-ignore //@ts-ignore
@ -127,9 +120,6 @@ export const TYPE_TRANSFORM_MAP: any = {
[undefined]: undefined, [undefined]: undefined,
parse: parseArrayString, parse: parseArrayString,
}, },
[FieldType.ATTACHMENT_SINGLE]: {
"": null,
},
[FieldType.BOOLEAN]: { [FieldType.BOOLEAN]: {
"": null, "": null,
//@ts-ignore //@ts-ignore

View File

@ -209,10 +209,22 @@ describe("rowProcessor - inputProcessing", () => {
const { row } = await inputProcessing(userId, table, newRow) const { row } = await inputProcessing(userId, table, newRow)
if (userValue === undefined) {
// The 'user' field is omitted
expect(row).toEqual({
name: "Jack",
})
} else {
// The update is processed if null or "". 'user' is changed to an empty array.
expect(row).toEqual({
name: "Jack",
user: [],
})
}
expect( expect(
bbReferenceProcessor.processInputBBReferences bbReferenceProcessor.processInputBBReferences
).not.toHaveBeenCalled() ).not.toHaveBeenCalled()
expect(row).toEqual(newRow)
} }
) )