@enact/webos 3.4.9-experimental-3 → 3.4.9-experimental-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/{build/LS2Request → LS2Request}/LS2Request.d.ts +0 -0
- package/LS2Request/LS2Request.js +228 -173
- package/LS2Request/tests/LS2Request-specs.js +85 -95
- package/{build/application → application}/application.d.ts +0 -0
- package/application/application.js +92 -70
- package/{build/deviceinfo → deviceinfo}/deviceinfo.d.ts +0 -0
- package/deviceinfo/deviceinfo.js +78 -62
- package/{build/index.d.ts → index.d.ts} +0 -0
- package/index.js +1 -0
- package/{build/keyboard → keyboard}/keyboard.d.ts +0 -0
- package/keyboard/keyboard.js +11 -4
- package/package.json +2 -2
- package/{build/platform → platform}/platform.d.ts +0 -0
- package/platform/platform.js +67 -65
- package/{build/pmloglib → pmloglib}/pmloglib.d.ts +0 -0
- package/pmloglib/pmloglib.js +116 -86
- package/speech/VoiceControlDecorator.js +99 -42
- package/{build/speech → speech}/index.d.ts +0 -0
- package/speech/index.js +23 -15
- package/speech/readAlert.js +78 -60
- package/build/CHANGELOG.md +0 -603
- package/build/LS2Request/LS2Request.js +0 -239
- package/build/LS2Request/package.json +0 -3
- package/build/LS2Request/tests/LS2Request-specs.js +0 -85
- package/build/README.md +0 -22
- package/build/application/application.js +0 -150
- package/build/application/package.json +0 -3
- package/build/deviceinfo/deviceinfo.js +0 -114
- package/build/deviceinfo/package.json +0 -3
- package/build/index.js +0 -2
- package/build/keyboard/keyboard.js +0 -27
- package/build/keyboard/package.json +0 -3
- package/build/package-lock.json +0 -221
- package/build/package.json +0 -33
- package/build/platform/package.json +0 -3
- package/build/platform/platform.js +0 -105
- package/build/pmloglib/package.json +0 -3
- package/build/pmloglib/pmloglib.js +0 -241
- package/build/speech/VoiceControlDecorator.js +0 -152
- package/build/speech/index.js +0 -23
- package/build/speech/package.json +0 -3
- package/build/speech/readAlert.js +0 -96
- package/docs/index.md +0 -8
- package/docs/luna-service-api.md +0 -35
- package/docs/webos-features.md +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
The following is a curated list of changes in the Enact webos module, newest changes on the top.
|
|
4
4
|
|
|
5
|
+
## [3.4.9-experimental-7] - 2021-11-24
|
|
6
|
+
|
|
7
|
+
No significant changes.
|
|
8
|
+
|
|
9
|
+
## [3.4.9-experimental-6] - 2021-04-07
|
|
10
|
+
|
|
11
|
+
No significant changes.
|
|
12
|
+
|
|
13
|
+
## [3.4.9-experimental-5] - 2021-03-17
|
|
14
|
+
|
|
15
|
+
No significant changes.
|
|
16
|
+
|
|
17
|
+
## [3.4.9-experimental-4] - 2021-02-23
|
|
18
|
+
|
|
19
|
+
No significant changes.
|
|
20
|
+
|
|
5
21
|
## [3.4.9-experimental-3] - 2021-01-26
|
|
6
22
|
|
|
7
23
|
No significant changes.
|
|
File without changes
|
package/LS2Request/LS2Request.js
CHANGED
|
@@ -1,184 +1,239 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Provides a class for making LS2 service requests on webOS platforms.
|
|
4
|
-
*
|
|
5
|
-
* @module webos/LS2Request
|
|
6
|
-
* @exports LS2Request
|
|
7
|
-
*/
|
|
1
|
+
"use strict";
|
|
8
2
|
|
|
9
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
var _util = require("@enact/core/util");
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
|
|
12
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
13
|
+
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
15
|
+
|
|
16
|
+
var refs = {};
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
var adjustPath = function adjustPath(path) {
|
|
19
|
+
if (!/^(luna|palm):\/\//.test(path)) path = 'luna://' + path;
|
|
20
|
+
if (path.slice(-1) !== '/') path += '/';
|
|
21
|
+
return path;
|
|
22
|
+
}; // default handlers
|
|
22
23
|
|
|
24
|
+
|
|
25
|
+
var failureHandler = function failureHandler(_ref) {
|
|
26
|
+
var errorText = _ref.errorText;
|
|
27
|
+
return console.error("LS2Request: ".concat(errorText));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var timeoutHandler = function timeoutHandler(_ref2) {
|
|
31
|
+
var errorText = _ref2.errorText;
|
|
32
|
+
return console.warn("LS2Request: ".concat(errorText));
|
|
33
|
+
};
|
|
23
34
|
/**
|
|
24
35
|
* A class for managing LS2 Requests.
|
|
25
36
|
*
|
|
26
37
|
* @memberof webos/LS2Request
|
|
27
38
|
* @class
|
|
28
39
|
*/
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
var LS2Request = /*#__PURE__*/function () {
|
|
43
|
+
/**
|
|
44
|
+
* Create a new LS2 request
|
|
45
|
+
*
|
|
46
|
+
* @memberof webos/LS2Request.LS2Request
|
|
47
|
+
* @constructor
|
|
48
|
+
*/
|
|
49
|
+
function LS2Request() {
|
|
50
|
+
var _this = this;
|
|
51
|
+
|
|
52
|
+
_classCallCheck(this, LS2Request);
|
|
53
|
+
|
|
54
|
+
this.timeoutJob = new _util.Job(function (_ref3) {
|
|
55
|
+
var onTimeout = _ref3.onTimeout,
|
|
56
|
+
timeout = _ref3.timeout;
|
|
57
|
+
onTimeout({
|
|
58
|
+
errorCode: -2,
|
|
59
|
+
errorText: "Request timed out after ".concat(timeout, " ms."),
|
|
60
|
+
returnValue: false
|
|
61
|
+
}); // cancel the request
|
|
62
|
+
|
|
63
|
+
_this.cancel();
|
|
64
|
+
});
|
|
65
|
+
this.bridge = null;
|
|
66
|
+
this.subscribe = false;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Send a request to an LS2 service method.
|
|
70
|
+
*
|
|
71
|
+
* @method
|
|
72
|
+
* @memberof webos/LS2Request.LS2Request.prototype
|
|
73
|
+
* @param {Object} options Options for the LS2 Request call
|
|
74
|
+
* @param {String} options.service The name of the LS2 service.
|
|
75
|
+
* @param {String} options.method The name of the method.
|
|
76
|
+
* @param {Object} options.parameters Any parameters required by the service method.
|
|
77
|
+
* @param {Function} options.onSuccess The success handler for the request.
|
|
78
|
+
* @param {Function} options.onFailure The failure handler for the request.
|
|
79
|
+
* @param {Function} options.onComplete The handler to run when the request
|
|
80
|
+
* is completed, regardless of return status.
|
|
81
|
+
* @param {Function} options.onTimeout The handler to run when the request
|
|
82
|
+
* times out. Used in conjunction with `timeout`.
|
|
83
|
+
* @param {Boolean} options.subscribe Subscribe to service methods that support subscription.
|
|
84
|
+
* @param {Number} options.timeout The delay in milliseconds to wait for the request to return.
|
|
85
|
+
* @returns {webos/LS2Request}
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
_createClass(LS2Request, [{
|
|
91
|
+
key: "send",
|
|
92
|
+
value: function send(_ref4) {
|
|
93
|
+
var _ref4$service = _ref4.service,
|
|
94
|
+
service = _ref4$service === void 0 ? '' : _ref4$service,
|
|
95
|
+
_ref4$method = _ref4.method,
|
|
96
|
+
method = _ref4$method === void 0 ? '' : _ref4$method,
|
|
97
|
+
_ref4$parameters = _ref4.parameters,
|
|
98
|
+
parameters = _ref4$parameters === void 0 ? {} : _ref4$parameters,
|
|
99
|
+
_ref4$onSuccess = _ref4.onSuccess,
|
|
100
|
+
onSuccess = _ref4$onSuccess === void 0 ? null : _ref4$onSuccess,
|
|
101
|
+
_ref4$onFailure = _ref4.onFailure,
|
|
102
|
+
onFailure = _ref4$onFailure === void 0 ? null : _ref4$onFailure,
|
|
103
|
+
_ref4$onComplete = _ref4.onComplete,
|
|
104
|
+
onComplete = _ref4$onComplete === void 0 ? null : _ref4$onComplete,
|
|
105
|
+
_ref4$onTimeout = _ref4.onTimeout,
|
|
106
|
+
onTimeout = _ref4$onTimeout === void 0 ? timeoutHandler : _ref4$onTimeout,
|
|
107
|
+
_ref4$subscribe = _ref4.subscribe,
|
|
108
|
+
subscribe = _ref4$subscribe === void 0 ? false : _ref4$subscribe,
|
|
109
|
+
_ref4$timeout = _ref4.timeout,
|
|
110
|
+
timeout = _ref4$timeout === void 0 ? 0 : _ref4$timeout;
|
|
111
|
+
this.cancelled = false;
|
|
112
|
+
|
|
113
|
+
if (!onFailure && !onComplete) {
|
|
114
|
+
onFailure = failureHandler;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (typeof window !== 'object' || !window.PalmServiceBridge) {
|
|
118
|
+
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
|
|
119
|
+
if (onFailure) onFailure({
|
|
120
|
+
errorCode: -1,
|
|
121
|
+
errorText: 'PalmServiceBridge not found.',
|
|
122
|
+
returnValue: false
|
|
123
|
+
});
|
|
124
|
+
if (onComplete) onComplete({
|
|
125
|
+
errorCode: -1,
|
|
126
|
+
errorText: 'PalmServiceBridge not found.',
|
|
127
|
+
returnValue: false
|
|
128
|
+
});
|
|
129
|
+
console.error('PalmServiceBridge not found.');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (this.ts && refs[this.ts]) {
|
|
134
|
+
delete refs[this.ts];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.subscribe = subscribe;
|
|
138
|
+
|
|
139
|
+
if (this.subscribe) {
|
|
140
|
+
parameters.subscribe = this.subscribe;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (parameters.subscribe) {
|
|
144
|
+
this.subscribe = parameters.subscribe;
|
|
145
|
+
} // eslint-disable-next-line no-undef
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
this.ts = performance.now();
|
|
149
|
+
refs[this.ts] = this; // eslint-disable-next-line no-undef
|
|
150
|
+
|
|
151
|
+
this.bridge = new PalmServiceBridge();
|
|
152
|
+
this.bridge.onservicecallback = this.callback.bind(this, onSuccess, onFailure, onComplete);
|
|
153
|
+
|
|
154
|
+
if (timeout) {
|
|
155
|
+
this.timeoutJob.startAfter(timeout, {
|
|
156
|
+
onTimeout: onTimeout,
|
|
157
|
+
timeout: timeout
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
this.bridge.call(adjustPath(service) + method, JSON.stringify(parameters));
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
}, {
|
|
165
|
+
key: "callback",
|
|
166
|
+
value: function callback(onSuccess, onFailure, onComplete, msg) {
|
|
167
|
+
if (this.cancelled) {
|
|
168
|
+
return;
|
|
169
|
+
} // remove timeout job
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
this.timeoutJob.stop();
|
|
173
|
+
var parsedMsg;
|
|
174
|
+
|
|
175
|
+
if (msg == null) {
|
|
176
|
+
parsedMsg = {
|
|
177
|
+
errorCode: -1,
|
|
178
|
+
errorText: "Invalid response: ".concat(msg),
|
|
179
|
+
returnValue: false
|
|
180
|
+
};
|
|
181
|
+
} else {
|
|
182
|
+
try {
|
|
183
|
+
parsedMsg = JSON.parse(msg);
|
|
184
|
+
} catch (e) {
|
|
185
|
+
parsedMsg = {
|
|
186
|
+
errorCode: -1,
|
|
187
|
+
errorText: msg,
|
|
188
|
+
returnValue: false
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (parsedMsg.errorCode || parsedMsg.returnValue === false) {
|
|
194
|
+
if (onFailure) {
|
|
195
|
+
onFailure(parsedMsg);
|
|
196
|
+
}
|
|
197
|
+
} else if (onSuccess) {
|
|
198
|
+
onSuccess(parsedMsg);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (onComplete) {
|
|
202
|
+
onComplete(parsedMsg);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (!this.subscribe) {
|
|
206
|
+
this.cancel();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Cancel the current LS2 request.
|
|
211
|
+
*
|
|
212
|
+
* @method
|
|
213
|
+
* @memberof webos/LS2Request.LS2Request.prototype
|
|
214
|
+
* @returns {undefined}
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
}, {
|
|
219
|
+
key: "cancel",
|
|
220
|
+
value: function cancel() {
|
|
221
|
+
// remove timeout job
|
|
222
|
+
this.timeoutJob.stop();
|
|
223
|
+
this.cancelled = true;
|
|
224
|
+
|
|
225
|
+
if (this.bridge) {
|
|
226
|
+
this.bridge.cancel();
|
|
227
|
+
this.bridge = null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (this.ts && refs[this.ts]) {
|
|
231
|
+
delete refs[this.ts];
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}]);
|
|
235
|
+
|
|
236
|
+
return LS2Request;
|
|
237
|
+
}();
|
|
238
|
+
|
|
239
|
+
exports["default"] = LS2Request;
|
|
@@ -1,95 +1,85 @@
|
|
|
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
|
-
request.callback(nop, nop, onComplete, failedResponse);
|
|
88
|
-
|
|
89
|
-
const expected = {errorCode: 101};
|
|
90
|
-
const actual = onComplete.mock.calls[0][0];
|
|
91
|
-
|
|
92
|
-
expect(actual).toMatchObject(expected);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _LS2Request = _interopRequireDefault(require("../LS2Request"));
|
|
4
|
+
|
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
+
|
|
7
|
+
describe('LS2Request', function () {
|
|
8
|
+
var nop = function nop() {};
|
|
9
|
+
|
|
10
|
+
describe('callback', function () {
|
|
11
|
+
var invalidResponse = '{invalid: json';
|
|
12
|
+
var failedResponse = '{"errorCode": 101}';
|
|
13
|
+
var successfulResponse = '{"returnValue": true}';
|
|
14
|
+
it('should return an error for a null msg', function () {
|
|
15
|
+
var request = new _LS2Request["default"]();
|
|
16
|
+
var onFailure = jest.fn();
|
|
17
|
+
request.callback(nop, onFailure, nop, null);
|
|
18
|
+
var expected = {
|
|
19
|
+
errorCode: -1
|
|
20
|
+
};
|
|
21
|
+
var actual = onFailure.mock.calls[0][0];
|
|
22
|
+
expect(actual).toMatchObject(expected);
|
|
23
|
+
});
|
|
24
|
+
it('should return an error for invalid JSON', function () {
|
|
25
|
+
var request = new _LS2Request["default"]();
|
|
26
|
+
var onFailure = jest.fn();
|
|
27
|
+
request.callback(nop, onFailure, nop);
|
|
28
|
+
var expected = {
|
|
29
|
+
errorCode: -1
|
|
30
|
+
};
|
|
31
|
+
var actual = onFailure.mock.calls[0][0];
|
|
32
|
+
expect(actual).toMatchObject(expected);
|
|
33
|
+
});
|
|
34
|
+
it('should invoke onFailure for a valid, failed request', function () {
|
|
35
|
+
var request = new _LS2Request["default"]();
|
|
36
|
+
var onFailure = jest.fn();
|
|
37
|
+
request.callback(nop, onFailure, nop, failedResponse);
|
|
38
|
+
var expected = {
|
|
39
|
+
errorCode: 101
|
|
40
|
+
};
|
|
41
|
+
var actual = onFailure.mock.calls[0][0];
|
|
42
|
+
expect(actual).toMatchObject(expected);
|
|
43
|
+
});
|
|
44
|
+
it('should invoke onSuccess for a valid request', function () {
|
|
45
|
+
var request = new _LS2Request["default"]();
|
|
46
|
+
var onSuccess = jest.fn();
|
|
47
|
+
request.callback(onSuccess, nop, nop, successfulResponse);
|
|
48
|
+
var expected = {
|
|
49
|
+
returnValue: true
|
|
50
|
+
};
|
|
51
|
+
var actual = onSuccess.mock.calls[0][0];
|
|
52
|
+
expect(actual).toMatchObject(expected);
|
|
53
|
+
});
|
|
54
|
+
it('should invoke onComplete for a valid request', function () {
|
|
55
|
+
var request = new _LS2Request["default"]();
|
|
56
|
+
var onComplete = jest.fn();
|
|
57
|
+
request.callback(nop, nop, onComplete, successfulResponse);
|
|
58
|
+
var expected = {
|
|
59
|
+
returnValue: true
|
|
60
|
+
};
|
|
61
|
+
var actual = onComplete.mock.calls[0][0];
|
|
62
|
+
expect(actual).toMatchObject(expected);
|
|
63
|
+
});
|
|
64
|
+
it('should invoke onComplete for an invalid request', function () {
|
|
65
|
+
var request = new _LS2Request["default"]();
|
|
66
|
+
var onComplete = jest.fn();
|
|
67
|
+
request.callback(nop, nop, onComplete, invalidResponse);
|
|
68
|
+
var expected = {
|
|
69
|
+
errorCode: -1
|
|
70
|
+
};
|
|
71
|
+
var actual = onComplete.mock.calls[0][0];
|
|
72
|
+
expect(actual).toMatchObject(expected);
|
|
73
|
+
});
|
|
74
|
+
it('should invoke onComplete for a valid, failed request', function () {
|
|
75
|
+
var request = new _LS2Request["default"]();
|
|
76
|
+
var onComplete = jest.fn();
|
|
77
|
+
request.callback(nop, nop, onComplete, failedResponse);
|
|
78
|
+
var expected = {
|
|
79
|
+
errorCode: 101
|
|
80
|
+
};
|
|
81
|
+
var actual = onComplete.mock.calls[0][0];
|
|
82
|
+
expect(actual).toMatchObject(expected);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
File without changes
|