1
0
Fork 0
mirror of synced 2024-07-12 09:45:48 +12:00

Test single attachment on outputProcessing

This commit is contained in:
Adria Navarro 2024-04-04 21:07:44 +02:00
parent 6928e7454c
commit 80dfef9c42

View file

@ -73,7 +73,7 @@ describe("rowProcessor - outputProcessing", () => {
)
})
it("should handle attachments correctly", async () => {
it("should handle attachment list correctly", async () => {
const table: Table = {
_id: generator.guid(),
name: "TestTable",
@ -116,6 +116,47 @@ describe("rowProcessor - outputProcessing", () => {
expect(output3.attach[0].url).toBe("aaaa")
})
it("should handle single attachment correctly", async () => {
const table: Table = {
_id: generator.guid(),
name: "TestTable",
type: "table",
sourceId: INTERNAL_TABLE_SOURCE_ID,
sourceType: TableSourceType.INTERNAL,
schema: {
attach: {
type: FieldType.ATTACHMENT_SINGLE,
name: "attach",
constraints: {},
},
},
}
const row: { attach: RowAttachment } = {
attach: {
size: 10,
name: "test",
extension: "jpg",
key: "test.jpg",
},
}
const output = await outputProcessing(table, row, { squash: false })
expect(output.attach.url).toBe(
"/files/signed/prod-budi-app-assets/test.jpg"
)
row.attach.url = ""
const output2 = await outputProcessing(table, row, { squash: false })
expect(output2.attach.url).toBe(
"/files/signed/prod-budi-app-assets/test.jpg"
)
row.attach.url = "aaaa"
const output3 = await outputProcessing(table, row, { squash: false })
expect(output3.attach.url).toBe("aaaa")
})
it("process output even when the field is not empty", async () => {
const table: Table = {
_id: generator.guid(),