Skip to content

Commit 302f9ba

Browse files
committed
feat: test disabled functionality
1 parent b070da3 commit 302f9ba

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

__tests__/controller.test.ts

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,8 +1873,8 @@ describe("Interactions toggler tests", () => {
18731873
it("Toggles defined functions", async () => {
18741874
const res = await handle(createMessage({
18751875
Action: "Toggle-Interactions",
1876-
Mint: "Enabled",
1877-
Borrow: "Disabled"
1876+
Mint: "Disabled",
1877+
Borrow: "Enabled"
18781878
}));
18791879

18801880
expect(res.Messages).toEqual(
@@ -1900,11 +1900,45 @@ describe("Interactions toggler tests", () => {
19001900
Tags: expect.arrayContaining([
19011901
expect.objectContaining({
19021902
name: "Enabled-Interactions",
1903-
value: expect.toBeJsonEncoded(expect.not.arrayContaining(["Borrow"]))
1903+
value: expect.toBeJsonEncoded(expect.not.arrayContaining(["Mint"]))
19041904
}),
19051905
expect.objectContaining({
19061906
name: "Disabled-Interactions",
1907-
value: expect.toBeJsonEncoded(expect.arrayContaining(["Borrow"]))
1907+
value: expect.toBeJsonEncoded(expect.arrayContaining(["Mint"]))
1908+
})
1909+
])
1910+
})
1911+
])
1912+
);
1913+
1914+
const sender = generateArweaveAddress();
1915+
const borrowRes = await handle(createMessage({
1916+
Action: "Credit-Notice",
1917+
"X-Action": "Mint",
1918+
Owner: tags["Collateral-Id"],
1919+
From: tags["Collateral-Id"],
1920+
"From-Process": tags["Collateral-Id"],
1921+
Quantity: "1",
1922+
Recipient: env.Process.Id,
1923+
Sender: sender
1924+
}));
1925+
const queueRes = await handle(createMessage({
1926+
"Queued-User": sender,
1927+
"X-Reference": normalizeTags(
1928+
getMessageByAction("Add-To-Queue", borrowRes.Messages)?.Tags || []
1929+
)["Reference"]
1930+
}));
1931+
1932+
expect(queueRes.Messages).toEqual(
1933+
expect.arrayContaining([
1934+
expect.objectContaining({
1935+
Target: sender,
1936+
Tags: expect.arrayContaining([
1937+
expect.objectContaining({
1938+
name: "Error",
1939+
value: expect.stringContaining(
1940+
"Minting is currently disabled"
1941+
)
19081942
})
19091943
])
19101944
})

0 commit comments

Comments
 (0)