This repository was archived by the owner on Apr 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy path3_then.js
More file actions
115 lines (101 loc) · 3.72 KB
/
3_then.js
File metadata and controls
115 lines (101 loc) · 3.72 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* LiskHQ/lisky
* Copyright © 2017 Lisk Foundation
*
* See the LICENSE file at the top-level directory of this distribution
* for licensing information.
*
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation,
* no part of this software, including this file, may be copied, modified,
* propagated, or distributed except according to the terms contained in the
* LICENSE file.
*
* Removal or modification of this copyright notice is prohibited.
*
*/
import lisk from 'lisk-js';
import { getFirstBoolean } from '../utils';
export function itShouldNotSetTheLiskAPIInstanceTestnetSetting() {
const { liskAPIInstance } = this.test.ctx;
return liskAPIInstance.setTestnet.should.not.be.called;
}
export function itShouldSetTheLiskAPIInstanceTestnetSettingTo() {
const { liskAPIInstance } = this.test.ctx;
const setting = getFirstBoolean(this.test.title);
return liskAPIInstance.setTestnet.firstCall.should.be.calledWith(setting);
}
export function itShouldSetTheLiskAPIInstanceTestnetSettingBackToTheOriginalSetting() {
const { liskAPIInstance } = this.test.ctx;
return liskAPIInstance.setTestnet.secondCall.should.be.calledWith(false);
}
export function itShouldUseTheLiskAPIInstanceToSendARequestToTheEndpointUsingTheParameters() {
const { liskAPIInstance, endpoint, parameters } = this.test.ctx;
return liskAPIInstance.sendRequest.should.be.calledWithExactly(
endpoint,
parameters,
);
}
export function itShouldNotBroadcastTheSignature() {
const { liskAPIInstance } = this.test.ctx;
return liskAPIInstance.broadcastSignatures.should.not.be.called;
}
export function itShouldBroadcastTheSignature() {
const { liskAPIInstance, signature } = this.test.ctx;
return liskAPIInstance.broadcastSignatures.should.be.calledWithExactly([
JSON.parse(signature),
]);
}
export function itShouldNotBroadcastTheTransaction() {
const { liskAPIInstance } = this.test.ctx;
return liskAPIInstance.broadcastTransaction.should.not.be.called;
}
export function itShouldBroadcastTheTransaction() {
const { liskAPIInstance, transaction } = this.test.ctx;
return liskAPIInstance.broadcastTransaction.should.be.calledWithExactly(
JSON.parse(transaction),
);
}
export function itShouldResolveToTheAPIResponse() {
const { returnValue, apiResponse } = this.test.ctx;
return returnValue.should.eventually.eql(apiResponse);
}
export function theLiskAPIInstanceShouldBeALiskJSAPIInstance() {
const { liskAPIInstance } = this.test.ctx;
return liskAPIInstance.should.be.instanceOf(lisk.api);
}
export function theLiskAPIInstanceShouldSendARequestToTheBlocksGetAPIEndpointWithTheBlockID() {
const { blockId, liskAPIInstance } = this.test.ctx;
const route = 'blocks/get';
const options = { id: blockId };
return liskAPIInstance.sendRequest.should.be.calledWithExactly(
route,
options,
);
}
export function theLiskAPIInstanceShouldSendARequestToTheAccountsAPIEndpointWithTheAddress() {
const { address, liskAPIInstance } = this.test.ctx;
const route = 'accounts';
const options = { address };
return liskAPIInstance.sendRequest.should.be.calledWithExactly(
route,
options,
);
}
export function theLiskAPIInstanceShouldSendARequestToTheTransactionsGetAPIEndpointWithTheTransactionID() {
const { transactionId, liskAPIInstance } = this.test.ctx;
const route = 'transactions/get';
const options = { id: transactionId };
return liskAPIInstance.sendRequest.should.be.calledWithExactly(
route,
options,
);
}
export function theLiskAPIInstanceShouldSendARequestToTheDelegatesGetAPIEndpointWithTheUsername() {
const { delegateUsername, liskAPIInstance } = this.test.ctx;
const route = 'delegates/get';
const options = { username: delegateUsername };
return liskAPIInstance.sendRequest.should.be.calledWithExactly(
route,
options,
);
}