Files
hardhat-simple-storage/test/test-deploy.js
2024-08-03 02:53:33 +08:00

34 lines
1.2 KiB
JavaScript

const { ethers } = require("hardhat");
const { expect, assert } = require("chai");
describe("SimpleStorage", function () {
let simpleStorageFactory;
let simpleStorage;
beforeEach(async function () {
simpleStorageFactory = await ethers.getContractFactory("SimpleStorage");
simpleStorage = await simpleStorageFactory.deploy();
});
it("Should start with a favorite number of 123", async function () {
const currentValue = await simpleStorage.viewMyNumber();
const expectedValue = "123";
// assert
assert.equal(currentValue.toString(), expectedValue);
// expect
//expect(currentValue.toString()).to.equal(expectedValue);
});
// Run this specific test only!
//it.only("Should update when we call storeMyNumber", async function () {
it("Should update when we call storeMyNumber", async function () {
const expectedValue = "7296";
const transactionResponse =
await simpleStorage.storeMyNumber(expectedValue);
await transactionResponse.wait(1);
const currentValue = await simpleStorage.viewMyNumber();
assert.equal(currentValue.toString(), expectedValue);
});
});