-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
32 lines (21 loc) · 1.03 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const SimpleStorage = artifacts.require("Storage");
const {BN, expectRevert, expectEvent} = require('@openzeppelin/test-helpers');
const {expect} = require('chai');
contract("SimpleStorage", accounts => {
beforeEach(async function () {
SimpleStorageInstance = await SimpleStorage.new({from: accounts[0]});
})
it("... should return the value 89", async() => {
await SimpleStorageInstance.store(89,{from: accounts[0]});
const storedData = await SimpleStorageInstance.retrieve.call();
assert.equal(storedData,89, "the value 89 was not stored");
expect(storedData).to.be.bignumber.equal(BN(89));
});
it("Should emit an Event with the value stored", async() => {
const result = await SimpleStorageInstance.store(89,{from: accounts[0]});
await expectEvent(result, 'stored',{_data:BN(89)});
})
it("Should retun an error when the value is <10", async() => {
await expectRevert(SimpleStorageInstance.store(2,{from: accounts[0]}), "j'aime pas ce nombre");
})
});