Skip to content

Commit be7d4b0

Browse files
committed
update tests in the test_app
1 parent 8c1b9b5 commit be7d4b0

File tree

2 files changed

+46
-42
lines changed

2 files changed

+46
-42
lines changed

test_app/app/js/test.js

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,56 @@
11

22
$(document).ready(function() {
33

4-
async.waterfall([
5-
function test1(callback) {
6-
AnotherStorage.simpleStorageAddress().then(function(simpleStorageAddress) {
7-
$("#tests").append("<br>test 1: " + (simpleStorageAddress === SimpleStorage.address));
8-
callback();
9-
});
10-
},
11-
function test2(callback) {
12-
SimpleStorage.storedData().then(function(result) {
13-
$("#tests").append("<br>test 2 (true first time): " + (result.toNumber() === 100));
14-
$("#tests").append("<br>test 2 (true after): " + (result.toNumber() === 150));
15-
callback();
16-
});
17-
},
18-
function test3(callback) {
19-
SimpleStorage.set(150).then(function() {
20-
SimpleStorage.get().then(function(result) {
21-
$("#tests").append("<br>test 3: " + (result.toNumber() === 150));
4+
document.getElementById("runTests").onclick = function() {
5+
async.waterfall([
6+
function test1(callback) {
7+
AnotherStorage.methods.simpleStorageAddress().call().then(function(simpleStorageAddress) {
8+
$("#tests").append("<br>test 1: " + (simpleStorageAddress === SimpleStorage._address));
229
callback();
2310
});
24-
});
25-
},
26-
function test4(callback) {
27-
$("#tests").append("<br>test 4: " + (Token.address === "undefined"));
28-
$("#tests").append("<br>test 4: " + (MyToken.address !== undefined));
29-
$("#tests").append("<br>test 4: " + (MyToken2.address !== undefined));
30-
callback();
31-
},
32-
function test5(callback) {
33-
MyToken._supply().then(function(result) {
34-
$("#tests").append("<br>test 5: " + (result.toNumber() === 1000));
11+
},
12+
function test2(callback) {
13+
SimpleStorage.methods.storedData().call().then(function(result) {
14+
$("#tests").append("<br>test 2 (true first time): " + (result === "100"));
15+
$("#tests").append("<br>test 2 (true after): " + (result === "150"));
16+
callback();
17+
});
18+
},
19+
function test3(callback) {
20+
SimpleStorage.methods.set(150).send({from: web3.eth.defaultAccount}).then(function() {
21+
SimpleStorage.methods.get().call().then(function(result) {
22+
$("#tests").append("<br>test 3: " + (result === "150"));
23+
callback();
24+
});
25+
});
26+
},
27+
function test4(callback) {
28+
$("#tests").append("<br>test 4: " + (Token._address === null));
29+
$("#tests").append("<br>test 4: " + (MyToken._address !== undefined));
30+
$("#tests").append("<br>test 4: " + (MyToken2._address !== undefined));
3531
callback();
36-
});
37-
},
38-
function test6(callback) {
39-
MyToken2._supply().then(function(result) {
40-
$("#tests").append("<br>test 6: " + (result.toNumber() === 2000));
32+
},
33+
function test5(callback) {
34+
MyToken.methods._supply().call().then(function(result) {
35+
$("#tests").append("<br>test 5: " + (result === "1000"));
36+
callback();
37+
});
38+
},
39+
function test6(callback) {
40+
MyToken2.methods._supply().call().then(function(result) {
41+
$("#tests").append("<br>test 6: " + (result === "2000"));
42+
callback();
43+
});
44+
},
45+
function test7(callback) {
46+
$("#tests").append("<br>test 7: " + (AlreadyDeployedToken._address === "0xeCE374063fE5Cc7EFbACA0a498477CaDA94E5AD6"));
4147
callback();
42-
});
43-
},
44-
function test7(callback) {
45-
$("#tests").append("<br>test 7: " + (AlreadyDeployedToken.address === "0x123"));
46-
callback();
47-
}
48-
], function (err, result) {
48+
}
49+
], function (err, result) {
4950
$("#tests").append("<br>done");
50-
});
51+
});
52+
53+
};
5154

5255
});
5356

test_app/app/test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
</head>
77
<body class="container">
88

9+
<button id="runTests">Run Tests</button>
910
<div id="tests"></div>
1011

1112
</body>

0 commit comments

Comments
 (0)