-
Notifications
You must be signed in to change notification settings - Fork 92
/
test.js
executable file
·41 lines (37 loc) · 1.37 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
33
34
35
36
37
38
39
40
41
// >> tests-snippet
describe("Greeter", function() {
let near;
let contract;
let accountId;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
// Common setup below
beforeAll(async function() {
if (window.testSettings === undefined) {
window.testSettings = {};
}
near = await nearlib.connect(testSettings);
accountId = testSettings.accountId;
const contractName = testSettings.contractName ?
testSettings.contractName :
(new URL(window.location.href)).searchParams.get("contractName");
contract = await near.loadContract(contractName, {
// NOTE: This configuration only needed while NEAR is still in development
// View methods are read only. They don't modify the state, but usually return some value.
viewMethods: ["hello"],
// Change methods can modify the state. But you don't receive the returned value when called.
changeMethods: [],
sender: accountId
});
});
// Multiple tests can be described below. Search Jasmine JS for documentation.
describe("simple", function() {
beforeAll(async function() {
// There can be some common setup for each test.
});
it("get hello message", async function() {
const result = await contract.hello();
expect(result).toBe("Hello, world");
});
});
});
// << tests-snippet