Skip to content

Commit

Permalink
test: select variant
Browse files Browse the repository at this point in the history
  • Loading branch information
blelump committed Apr 9, 2024
1 parent 2e9cba0 commit f8cdb50
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,50 @@ ADD LABEL pl ATTRS address="Adres"
})
})
})

describe("i a", () => {
describe("select variants", () => {
const ocafile = `ADD ATTRIBUTE multi=Array[Text]
ADD ENTRY_CODE ATTRS multi=["o1", "o2", "o3", "o4", "o5", "o6", "o7"]
ADD ENTRY en ATTRS multi={"o1": "One", "o2": "Two", "o3": "Three", "o4": "Four", "o5": "Five", "o6": "Six", "o7": "Seven"}
ADD LABEL en ATTRS multi="Multi"
`
let bundleSAID = null
beforeAll(async () => {
let bundleResp = await axios.post(`${OCA_REPO}/api/oca-bundles`, ocafile)
expect(bundleResp.data).toHaveProperty("said")
bundleSAID = bundleResp.data.said
})

test("creates object graph", async () => {
const bundle = await axios.get(`${OCA_REPO}/api/oca-bundles/${bundleSAID}?w=true`)
const pres = {
v: "1.0.0",
bd: bundleSAID,
l: ["eng"],
d: "EK0T5StXlcYwIhfp_wJxhIpYwYpEnMhHwnKbHnodhxFU",
p: [{ ns: "page 1", ao: ["multi"] }],
po: ["page 1"],
pl: {
eng: {
"page 1": "First page",
},
},
i: [
{
m: "web", // interaction method
c: "capture", // context
a: {
multi: { t: "select", va: "multiple" },
},
},
],
}
const result = await from(bundle.data, pres, {})
console.dir(result, { depth: null })
expect(result.form.pages[0].fields[0].field.type).toBe("choice")
expect(result.form.pages[0].fields[0].field.display.type).toBe("select-multiple")
})
})
})
})

0 comments on commit f8cdb50

Please sign in to comment.