Skip to content

Commit

Permalink
feat(usable-token): update test
Browse files Browse the repository at this point in the history
- Expect allowance to be a mapping(address => uint)
  • Loading branch information
nprimo committed Mar 7, 2024
1 parent b58ba30 commit 4f383b7
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/sol/usable-token.test.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
const { expect } = require("chai")
const { expect } = require('chai')

describe("Usable token (Allowances)", function() {
describe('Usable token (Allowances)', function () {
let minito, owner, alice, bob

beforeEach(async ()=>{
const contractDeployer = await ethers.getContractFactory("UsableToken");
[owner, alice, bob] = await ethers.getSigners()
beforeEach(async () => {
const contractDeployer = await ethers.getContractFactory('UsableToken')
;[owner, alice, bob] = await ethers.getSigners()
minito = await contractDeployer.deploy(200)
await minito.deployed()
})
it("Deploy account should have 200 units ", async function() {
it('Deploy account should have 200 units ', async function () {
expect(await minito.accounts(owner.address)).to.equal(200)
})

it("Too large transaction should fail", async function() {
await expect( minito.transfer(alice.address, 2000)).to.be.reverted
it('Too large transaction should fail', async function () {
await expect(minito.transfer(alice.address, 2000)).to.be.reverted
})
it("Transfer should change balances", async function() {
it('Transfer should change balances', async function () {
await minito.transfer(alice.address, 150)
expect(await minito.accounts(alice.address)).to.equal(150)

})

it("Owner can approve and allowance corresponds", async function() {
it('Owner can approve and allowance corresponds', async function () {
await minito.approve(alice.address, 23)
expect(await minito.allowance(owner.address, alice.address)).to.equal(23)
expect(await minito.allowance(alice.address)).to.equal(23)
})

it("Too large transferFrom should fail", async function() {
it('Too large transferFrom should fail', async function () {
await minito.approve(bob.address, 23)

await expect( minito.connect(bob).transferFrom(owner.address, alice.address, 2000)).to.be.reverted
await expect(
minito.connect(bob).transferFrom(owner.address, alice.address, 2000),
).to.be.reverted
})

})

0 comments on commit 4f383b7

Please sign in to comment.