Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions tests/todo-list-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,25 @@ describe("todo-list-app", () => {
// assert.equal(taskAccount.isDone, true);
// });

// it("cannot create a task with more than 400 characters", async () => {
// const task = anchor.web3.Keypair.generate();
// try {
// await program.methods
// .addingTask("You are awesome".repeat(100))
// .accounts({
// task: task.publicKey,
// author: author.wallet.publicKey,
// systemProgram: anchor.web3.SystemProgram.programId,
// })
// .signers([task])
// .rpc();
// assert.fail("Expected an error");
// } catch (err) {
// assert.equal(err.toString(), "Error: failed to send transaction");
// }
// });
it("cannot create a task with more than 400 characters", async () => {
const task = anchor.web3.Keypair.generate();
try {
// Adjust the string length as needed
const longString = "You are awesome".repeat(25); // Adjust to find the right length
await program.methods
.addingTask(longString)
.accounts({
task: task.publicKey,
author: author.wallet.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
})
.signers([task])
.rpc();
assert.fail("Expected a TextTooLong error");
} catch (err) {
// Check for specific smart contract error
assert.include(err.toString(), "TextTooLong");
}
});

});