@webex/internal-plugin-flag 3.0.0-beta.8 → 3.0.0-beta.80
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/README.md +1 -3
- package/dist/config.js +0 -3
- package/dist/config.js.map +1 -1
- package/dist/flag.js +96 -144
- package/dist/flag.js.map +1 -1
- package/dist/index.js +1 -9
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/config.js +1 -2
- package/src/flag.js +48 -57
- package/src/index.js +2 -2
- package/test/integration/spec/flag.js +98 -79
- package/test/unit/spec/flag.js +10 -6
package/README.md
CHANGED
|
@@ -21,14 +21,12 @@ npm install --save @webex/internal-plugin-flag
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
23
|
```js
|
|
24
|
-
|
|
25
24
|
import '@webex/internal-plugin-flag';
|
|
26
25
|
|
|
27
26
|
import WebexCore from '@webex/webex-core';
|
|
28
27
|
|
|
29
28
|
const webex = new WebexCore();
|
|
30
|
-
webex.internal.flag.WHATEVER
|
|
31
|
-
|
|
29
|
+
webex.internal.flag.WHATEVER;
|
|
32
30
|
```
|
|
33
31
|
|
|
34
32
|
## Maintainers
|
package/dist/config.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
|
|
9
7
|
exports.default = void 0;
|
|
10
|
-
|
|
11
8
|
/*!
|
|
12
9
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
13
10
|
*/
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["flag"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nexport default {\n flag: {
|
|
1
|
+
{"version":3,"names":["flag"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nexport default {\n flag: {},\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAFA,eAIe;EACbA,IAAI,EAAE,CAAC;AACT,CAAC;AAAA"}
|
package/dist/flag.js
CHANGED
|
@@ -1,59 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Array$from2 = require("@babel/runtime-corejs2/core-js/array/from");
|
|
4
|
-
|
|
5
4
|
var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
|
|
6
|
-
|
|
7
5
|
var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
|
|
8
|
-
|
|
9
6
|
var _Array$isArray = require("@babel/runtime-corejs2/core-js/array/is-array");
|
|
10
|
-
|
|
11
7
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
12
|
-
|
|
13
8
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
14
|
-
|
|
15
9
|
_Object$defineProperty(exports, "__esModule", {
|
|
16
10
|
value: true
|
|
17
11
|
});
|
|
18
|
-
|
|
19
12
|
exports.default = void 0;
|
|
20
|
-
|
|
21
13
|
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
22
|
-
|
|
23
14
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
24
|
-
|
|
25
15
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/map"));
|
|
26
|
-
|
|
27
16
|
var _from = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/from"));
|
|
28
|
-
|
|
29
17
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
30
|
-
|
|
31
18
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
32
|
-
|
|
33
19
|
var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
|
|
34
|
-
|
|
35
20
|
var _webexCore = require("@webex/webex-core");
|
|
36
|
-
|
|
37
21
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && o[_Symbol$iterator] || o["@@iterator"]; if (!it) { if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
38
|
-
|
|
39
22
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from2(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
40
|
-
|
|
41
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
42
|
-
|
|
23
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
43
24
|
var Flag = _webexCore.WebexPlugin.extend({
|
|
44
25
|
namespace: 'Flag',
|
|
45
|
-
|
|
46
26
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
27
|
+
* Archive a flag
|
|
28
|
+
* @param {Object} flag
|
|
29
|
+
* @param {Object} options
|
|
30
|
+
* @returns {Promise<Object>} Resolves with the flag archival
|
|
31
|
+
*/
|
|
52
32
|
archive: function archive(flag, options) {
|
|
53
33
|
if (!flag.url) {
|
|
54
34
|
return _promise.default.reject(new Error('`flag.url` is required'));
|
|
55
35
|
}
|
|
56
|
-
|
|
57
36
|
options = options || {};
|
|
58
37
|
var params = {
|
|
59
38
|
method: 'PUT',
|
|
@@ -67,18 +46,16 @@ var Flag = _webexCore.WebexPlugin.extend({
|
|
|
67
46
|
return res.body;
|
|
68
47
|
});
|
|
69
48
|
},
|
|
70
|
-
|
|
71
49
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
50
|
+
* Flags an activity
|
|
51
|
+
* @param {Object} activity
|
|
52
|
+
* @param {Object} options
|
|
53
|
+
* @returns {Promise<Object>} Resolves with the flag creation
|
|
54
|
+
*/
|
|
77
55
|
create: function create(activity, options) {
|
|
78
56
|
if (!activity.url) {
|
|
79
57
|
return _promise.default.reject(new Error('`activity.url` is required'));
|
|
80
58
|
}
|
|
81
|
-
|
|
82
59
|
options = options || {};
|
|
83
60
|
var params = {
|
|
84
61
|
method: 'POST',
|
|
@@ -95,12 +72,11 @@ var Flag = _webexCore.WebexPlugin.extend({
|
|
|
95
72
|
return res.body;
|
|
96
73
|
});
|
|
97
74
|
},
|
|
98
|
-
|
|
99
75
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
76
|
+
* Gets a list of Flags for a user
|
|
77
|
+
* @param {Object} options
|
|
78
|
+
* @returns {Promise} Resolves with the fetched flags
|
|
79
|
+
*/
|
|
104
80
|
list: function list(options) {
|
|
105
81
|
options = options || {};
|
|
106
82
|
var params = {
|
|
@@ -116,120 +92,99 @@ var Flag = _webexCore.WebexPlugin.extend({
|
|
|
116
92
|
return res.body.items;
|
|
117
93
|
});
|
|
118
94
|
},
|
|
119
|
-
|
|
120
95
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
96
|
+
* Gets an array of activities where the status is 200
|
|
97
|
+
* @param {Object} flags
|
|
98
|
+
* @returns {Promise<Object>} Resolves with the activities
|
|
99
|
+
* TODO: this should be implemented as a batched request when migrating to the modular sdk
|
|
100
|
+
*/
|
|
126
101
|
mapToActivities: function mapToActivities(flags) {
|
|
127
102
|
var _this = this;
|
|
128
|
-
|
|
129
103
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
130
104
|
var mapUrlActivities, _iterator, _step, flag, convoUrlRegex, activity, match, url, activities, responses;
|
|
131
|
-
|
|
132
105
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
133
|
-
while (1) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (!activities) {
|
|
151
|
-
activities = [];
|
|
152
|
-
mapUrlActivities.set(url, activities);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
activities.push(activity);
|
|
156
|
-
} else {
|
|
157
|
-
_this.logger.warn("The activity URL has a strange format (".concat(activity, "). Ignoring it."));
|
|
106
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
107
|
+
case 0:
|
|
108
|
+
mapUrlActivities = new _map.default();
|
|
109
|
+
_iterator = _createForOfIteratorHelper(flags);
|
|
110
|
+
try {
|
|
111
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
112
|
+
flag = _step.value;
|
|
113
|
+
convoUrlRegex = /(.*)\/activities\//;
|
|
114
|
+
activity = flag['flag-item'];
|
|
115
|
+
match = convoUrlRegex.exec(activity);
|
|
116
|
+
if (match) {
|
|
117
|
+
url = match[1];
|
|
118
|
+
activities = mapUrlActivities.get(url);
|
|
119
|
+
if (!activities) {
|
|
120
|
+
activities = [];
|
|
121
|
+
mapUrlActivities.set(url, activities);
|
|
158
122
|
}
|
|
123
|
+
activities.push(activity);
|
|
124
|
+
} else {
|
|
125
|
+
_this.logger.warn("The activity URL has a strange format (".concat(activity, "). Ignoring it."));
|
|
159
126
|
}
|
|
160
|
-
} catch (err) {
|
|
161
|
-
_iterator.e(err);
|
|
162
|
-
} finally {
|
|
163
|
-
_iterator.f();
|
|
164
127
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return _context2.abrupt("return", (0, _flatten2.default)(responses));
|
|
212
|
-
|
|
213
|
-
case 7:
|
|
214
|
-
case "end":
|
|
215
|
-
return _context2.stop();
|
|
216
|
-
}
|
|
128
|
+
} catch (err) {
|
|
129
|
+
_iterator.e(err);
|
|
130
|
+
} finally {
|
|
131
|
+
_iterator.f();
|
|
132
|
+
}
|
|
133
|
+
_context2.next = 5;
|
|
134
|
+
return _promise.default.all((0, _from.default)(mapUrlActivities, /*#__PURE__*/function () {
|
|
135
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
136
|
+
var _ref3, convoUrl, activityUrls, params, res;
|
|
137
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
138
|
+
while (1) switch (_context.prev = _context.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
_ref3 = (0, _slicedToArray2.default)(_ref, 2), convoUrl = _ref3[0], activityUrls = _ref3[1];
|
|
141
|
+
params = {
|
|
142
|
+
method: 'POST',
|
|
143
|
+
url: "".concat(convoUrl, "/bulk_activities_fetch"),
|
|
144
|
+
body: {
|
|
145
|
+
activityUrls: activityUrls
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
_context.next = 4;
|
|
149
|
+
return _this.webex.request(params);
|
|
150
|
+
case 4:
|
|
151
|
+
res = _context.sent;
|
|
152
|
+
return _context.abrupt("return", res.body.multistatus.reduce(function (activitiesArr, statusData) {
|
|
153
|
+
if (statusData.status === '200') {
|
|
154
|
+
activitiesArr.push(statusData.data.activity);
|
|
155
|
+
}
|
|
156
|
+
return activitiesArr;
|
|
157
|
+
}, []));
|
|
158
|
+
case 6:
|
|
159
|
+
case "end":
|
|
160
|
+
return _context.stop();
|
|
161
|
+
}
|
|
162
|
+
}, _callee);
|
|
163
|
+
}));
|
|
164
|
+
return function (_x) {
|
|
165
|
+
return _ref2.apply(this, arguments);
|
|
166
|
+
};
|
|
167
|
+
}()));
|
|
168
|
+
case 5:
|
|
169
|
+
responses = _context2.sent;
|
|
170
|
+
return _context2.abrupt("return", (0, _flatten2.default)(responses));
|
|
171
|
+
case 7:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context2.stop();
|
|
217
174
|
}
|
|
218
175
|
}, _callee2);
|
|
219
176
|
}))();
|
|
220
177
|
},
|
|
221
|
-
|
|
222
178
|
/**
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
179
|
+
* Delete a flag
|
|
180
|
+
* @param {Object} flag
|
|
181
|
+
* @param {Object} options
|
|
182
|
+
* @returns {Promise<Object>} Resolves with the flag deletion
|
|
183
|
+
*/
|
|
228
184
|
delete: function _delete(flag, options) {
|
|
229
185
|
if (!flag.url) {
|
|
230
186
|
return _promise.default.reject(new Error('`flag.url` is required'));
|
|
231
187
|
}
|
|
232
|
-
|
|
233
188
|
options = options || {};
|
|
234
189
|
var params = {
|
|
235
190
|
method: 'DELETE',
|
|
@@ -240,18 +195,16 @@ var Flag = _webexCore.WebexPlugin.extend({
|
|
|
240
195
|
return res.body;
|
|
241
196
|
});
|
|
242
197
|
},
|
|
243
|
-
|
|
244
198
|
/**
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
199
|
+
* UnFlags an activity
|
|
200
|
+
* @param {Object} flag
|
|
201
|
+
* @param {Object} options
|
|
202
|
+
* @returns {Promise<Object>} Resolves with the flag removal
|
|
203
|
+
*/
|
|
250
204
|
unflag: function unflag(flag, options) {
|
|
251
205
|
if (!flag.url) {
|
|
252
206
|
return _promise.default.reject(new Error('`flag.url` is required'));
|
|
253
207
|
}
|
|
254
|
-
|
|
255
208
|
options = options || {};
|
|
256
209
|
var params = {
|
|
257
210
|
method: 'PUT',
|
|
@@ -265,9 +218,8 @@ var Flag = _webexCore.WebexPlugin.extend({
|
|
|
265
218
|
return res.body;
|
|
266
219
|
});
|
|
267
220
|
},
|
|
268
|
-
version: "3.0.0-beta.
|
|
221
|
+
version: "3.0.0-beta.80"
|
|
269
222
|
});
|
|
270
|
-
|
|
271
223
|
var _default = Flag;
|
|
272
224
|
exports.default = _default;
|
|
273
225
|
//# sourceMappingURL=flag.js.map
|
package/dist/flag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Flag","WebexPlugin","extend","namespace","archive","flag","options","url","reject","Error","params","method","uri","body","state","webex","request","then","res","create","activity","service","resource","target","list","qs","items","mapToActivities","flags","mapUrlActivities","convoUrlRegex","match","exec","activities","get","set","push","logger","warn","all","convoUrl","activityUrls","multistatus","reduce","activitiesArr","statusData","status","data","responses","delete","unflag"],"sources":["flag.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nimport {flatten} from 'lodash';\nimport {WebexPlugin} from '@webex/webex-core';\n\nconst Flag = WebexPlugin.extend({\n namespace: 'Flag',\n\n /**\n
|
|
1
|
+
{"version":3,"names":["Flag","WebexPlugin","extend","namespace","archive","flag","options","url","reject","Error","params","method","uri","body","state","webex","request","then","res","create","activity","service","resource","target","list","qs","items","mapToActivities","flags","mapUrlActivities","convoUrlRegex","match","exec","activities","get","set","push","logger","warn","all","convoUrl","activityUrls","multistatus","reduce","activitiesArr","statusData","status","data","responses","delete","unflag"],"sources":["flag.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\nimport {flatten} from 'lodash';\nimport {WebexPlugin} from '@webex/webex-core';\n\nconst Flag = WebexPlugin.extend({\n namespace: 'Flag',\n\n /**\n * Archive a flag\n * @param {Object} flag\n * @param {Object} options\n * @returns {Promise<Object>} Resolves with the flag archival\n */\n archive(flag, options) {\n if (!flag.url) {\n return Promise.reject(new Error('`flag.url` is required'));\n }\n options = options || {};\n const params = {\n method: 'PUT',\n uri: flag.url,\n options,\n body: {\n state: 'archived',\n },\n };\n\n return this.webex.request(params).then((res) => res.body);\n },\n\n /**\n * Flags an activity\n * @param {Object} activity\n * @param {Object} options\n * @returns {Promise<Object>} Resolves with the flag creation\n */\n create(activity, options) {\n if (!activity.url) {\n return Promise.reject(new Error('`activity.url` is required'));\n }\n options = options || {};\n const params = {\n method: 'POST',\n service: 'userApps',\n resource: '/flags',\n options,\n body: {\n 'conversation-url': activity.target.url,\n 'flag-item': activity.url,\n state: 'flagged',\n },\n };\n\n return this.webex.request(params).then((res) => res.body);\n },\n\n /**\n * Gets a list of Flags for a user\n * @param {Object} options\n * @returns {Promise} Resolves with the fetched flags\n */\n list(options) {\n options = options || {};\n const params = {\n method: 'GET',\n service: 'userApps',\n resource: '/flags',\n options,\n qs: {\n state: 'flagged',\n },\n };\n\n return this.webex.request(params).then((res) => res.body.items);\n },\n\n /**\n * Gets an array of activities where the status is 200\n * @param {Object} flags\n * @returns {Promise<Object>} Resolves with the activities\n * TODO: this should be implemented as a batched request when migrating to the modular sdk\n */\n async mapToActivities(flags) {\n const mapUrlActivities = new Map();\n\n for (const flag of flags) {\n const convoUrlRegex = /(.*)\\/activities\\//;\n const activity = flag['flag-item'];\n const match = convoUrlRegex.exec(activity);\n\n if (match) {\n const url = match[1];\n let activities = mapUrlActivities.get(url);\n\n if (!activities) {\n activities = [];\n mapUrlActivities.set(url, activities);\n }\n activities.push(activity);\n } else {\n this.logger.warn(`The activity URL has a strange format (${activity}). Ignoring it.`);\n }\n }\n\n const responses = await Promise.all(\n Array.from(mapUrlActivities, async ([convoUrl, activityUrls]) => {\n const params = {\n method: 'POST',\n url: `${convoUrl}/bulk_activities_fetch`,\n body: {\n activityUrls,\n },\n };\n\n const res = await this.webex.request(params);\n\n return res.body.multistatus.reduce((activitiesArr, statusData) => {\n if (statusData.status === '200') {\n activitiesArr.push(statusData.data.activity);\n }\n\n return activitiesArr;\n }, []);\n })\n );\n\n return flatten(responses);\n },\n\n /**\n * Delete a flag\n * @param {Object} flag\n * @param {Object} options\n * @returns {Promise<Object>} Resolves with the flag deletion\n */\n delete(flag, options) {\n if (!flag.url) {\n return Promise.reject(new Error('`flag.url` is required'));\n }\n options = options || {};\n const params = {\n method: 'DELETE',\n options,\n uri: flag.url,\n };\n\n return this.request(params).then((res) => res.body);\n },\n\n /**\n * UnFlags an activity\n * @param {Object} flag\n * @param {Object} options\n * @returns {Promise<Object>} Resolves with the flag removal\n */\n unflag(flag, options) {\n if (!flag.url) {\n return Promise.reject(new Error('`flag.url` is required'));\n }\n options = options || {};\n const params = {\n method: 'PUT',\n uri: flag.url,\n options,\n body: {\n state: 'unflagged',\n },\n };\n\n return this.webex.request(params).then((res) => res.body);\n },\n});\n\nexport default Flag;\n"],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
_Object$defineProperty(exports, "default", {
|
|
12
9
|
enumerable: true,
|
|
13
10
|
get: function get() {
|
|
14
11
|
return _flag.default;
|
|
15
12
|
}
|
|
16
13
|
});
|
|
17
|
-
|
|
18
14
|
var _webexCore = require("@webex/webex-core");
|
|
19
|
-
|
|
20
15
|
require("@webex/internal-plugin-conversation");
|
|
21
|
-
|
|
22
16
|
require("@webex/internal-plugin-device");
|
|
23
|
-
|
|
24
17
|
var _flag = _interopRequireDefault(require("./flag"));
|
|
25
|
-
|
|
26
18
|
var _config = _interopRequireDefault(require("./config"));
|
|
27
|
-
|
|
28
19
|
/*!
|
|
29
20
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
30
21
|
*/
|
|
22
|
+
|
|
31
23
|
(0, _webexCore.registerInternalPlugin)('flag', _flag.default, {
|
|
32
24
|
config: _config.default,
|
|
33
25
|
payloadTransformer: {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerInternalPlugin","Flag","config","payloadTransformer","predicates","transforms"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerInternalPlugin} from '@webex/webex-core';\n\nimport '@webex/internal-plugin-conversation';\nimport '@webex/internal-plugin-device';\nimport Flag from './flag';\nimport config from './config';\n\nregisterInternalPlugin('flag', Flag, {\n config,\n payloadTransformer: {\n predicates: [],\n transforms: []
|
|
1
|
+
{"version":3,"names":["registerInternalPlugin","Flag","config","payloadTransformer","predicates","transforms"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerInternalPlugin} from '@webex/webex-core';\n\nimport '@webex/internal-plugin-conversation';\nimport '@webex/internal-plugin-device';\nimport Flag from './flag';\nimport config from './config';\n\nregisterInternalPlugin('flag', Flag, {\n config,\n payloadTransformer: {\n predicates: [],\n transforms: [],\n },\n});\n\nexport {default} from './flag';\n"],"mappings":";;;;;;;;;;;;;AAIA;AAEA;AACA;AACA;AACA;AATA;AACA;AACA;;AASA,IAAAA,iCAAsB,EAAC,MAAM,EAAEC,aAAI,EAAE;EACnCC,MAAM,EAANA,eAAM;EACNC,kBAAkB,EAAE;IAClBC,UAAU,EAAE,EAAE;IACdC,UAAU,EAAE;EACd;AACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/internal-plugin-flag",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.80",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Saurabh Jain <saurjai3@cisco.com>",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@webex/internal-plugin-conversation": "3.0.0-beta.
|
|
25
|
-
"@webex/internal-plugin-device": "3.0.0-beta.
|
|
26
|
-
"@webex/internal-plugin-flag": "3.0.0-beta.
|
|
27
|
-
"@webex/test-helper-chai": "3.0.0-beta.
|
|
28
|
-
"@webex/test-helper-mock-webex": "3.0.0-beta.
|
|
29
|
-
"@webex/test-helper-test-users": "3.0.0-beta.
|
|
30
|
-
"@webex/webex-core": "3.0.0-beta.
|
|
24
|
+
"@webex/internal-plugin-conversation": "3.0.0-beta.80",
|
|
25
|
+
"@webex/internal-plugin-device": "3.0.0-beta.80",
|
|
26
|
+
"@webex/internal-plugin-flag": "3.0.0-beta.80",
|
|
27
|
+
"@webex/test-helper-chai": "3.0.0-beta.80",
|
|
28
|
+
"@webex/test-helper-mock-webex": "3.0.0-beta.80",
|
|
29
|
+
"@webex/test-helper-test-users": "3.0.0-beta.80",
|
|
30
|
+
"@webex/webex-core": "3.0.0-beta.80",
|
|
31
31
|
"lodash": "^4.17.21"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/config.js
CHANGED
package/src/flag.js
CHANGED
|
@@ -8,11 +8,11 @@ const Flag = WebexPlugin.extend({
|
|
|
8
8
|
namespace: 'Flag',
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
* Archive a flag
|
|
12
|
+
* @param {Object} flag
|
|
13
|
+
* @param {Object} options
|
|
14
|
+
* @returns {Promise<Object>} Resolves with the flag archival
|
|
15
|
+
*/
|
|
16
16
|
archive(flag, options) {
|
|
17
17
|
if (!flag.url) {
|
|
18
18
|
return Promise.reject(new Error('`flag.url` is required'));
|
|
@@ -23,20 +23,19 @@ const Flag = WebexPlugin.extend({
|
|
|
23
23
|
uri: flag.url,
|
|
24
24
|
options,
|
|
25
25
|
body: {
|
|
26
|
-
state: 'archived'
|
|
27
|
-
}
|
|
26
|
+
state: 'archived',
|
|
27
|
+
},
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
return this.webex.request(params)
|
|
31
|
-
.then((res) => res.body);
|
|
30
|
+
return this.webex.request(params).then((res) => res.body);
|
|
32
31
|
},
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
* Flags an activity
|
|
35
|
+
* @param {Object} activity
|
|
36
|
+
* @param {Object} options
|
|
37
|
+
* @returns {Promise<Object>} Resolves with the flag creation
|
|
38
|
+
*/
|
|
40
39
|
create(activity, options) {
|
|
41
40
|
if (!activity.url) {
|
|
42
41
|
return Promise.reject(new Error('`activity.url` is required'));
|
|
@@ -50,19 +49,18 @@ const Flag = WebexPlugin.extend({
|
|
|
50
49
|
body: {
|
|
51
50
|
'conversation-url': activity.target.url,
|
|
52
51
|
'flag-item': activity.url,
|
|
53
|
-
state: 'flagged'
|
|
54
|
-
}
|
|
52
|
+
state: 'flagged',
|
|
53
|
+
},
|
|
55
54
|
};
|
|
56
55
|
|
|
57
|
-
return this.webex.request(params)
|
|
58
|
-
.then((res) => res.body);
|
|
56
|
+
return this.webex.request(params).then((res) => res.body);
|
|
59
57
|
},
|
|
60
58
|
|
|
61
59
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
* Gets a list of Flags for a user
|
|
61
|
+
* @param {Object} options
|
|
62
|
+
* @returns {Promise} Resolves with the fetched flags
|
|
63
|
+
*/
|
|
66
64
|
list(options) {
|
|
67
65
|
options = options || {};
|
|
68
66
|
const params = {
|
|
@@ -71,20 +69,19 @@ const Flag = WebexPlugin.extend({
|
|
|
71
69
|
resource: '/flags',
|
|
72
70
|
options,
|
|
73
71
|
qs: {
|
|
74
|
-
state: 'flagged'
|
|
75
|
-
}
|
|
72
|
+
state: 'flagged',
|
|
73
|
+
},
|
|
76
74
|
};
|
|
77
75
|
|
|
78
|
-
return this.webex.request(params)
|
|
79
|
-
.then((res) => res.body.items);
|
|
76
|
+
return this.webex.request(params).then((res) => res.body.items);
|
|
80
77
|
},
|
|
81
78
|
|
|
82
79
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
* Gets an array of activities where the status is 200
|
|
81
|
+
* @param {Object} flags
|
|
82
|
+
* @returns {Promise<Object>} Resolves with the activities
|
|
83
|
+
* TODO: this should be implemented as a batched request when migrating to the modular sdk
|
|
84
|
+
*/
|
|
88
85
|
async mapToActivities(flags) {
|
|
89
86
|
const mapUrlActivities = new Map();
|
|
90
87
|
|
|
@@ -102,11 +99,8 @@ const Flag = WebexPlugin.extend({
|
|
|
102
99
|
mapUrlActivities.set(url, activities);
|
|
103
100
|
}
|
|
104
101
|
activities.push(activity);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
this.logger.warn(
|
|
108
|
-
`The activity URL has a strange format (${activity}). Ignoring it.`
|
|
109
|
-
);
|
|
102
|
+
} else {
|
|
103
|
+
this.logger.warn(`The activity URL has a strange format (${activity}). Ignoring it.`);
|
|
110
104
|
}
|
|
111
105
|
}
|
|
112
106
|
|
|
@@ -116,8 +110,8 @@ const Flag = WebexPlugin.extend({
|
|
|
116
110
|
method: 'POST',
|
|
117
111
|
url: `${convoUrl}/bulk_activities_fetch`,
|
|
118
112
|
body: {
|
|
119
|
-
activityUrls
|
|
120
|
-
}
|
|
113
|
+
activityUrls,
|
|
114
|
+
},
|
|
121
115
|
};
|
|
122
116
|
|
|
123
117
|
const res = await this.webex.request(params);
|
|
@@ -136,11 +130,11 @@ const Flag = WebexPlugin.extend({
|
|
|
136
130
|
},
|
|
137
131
|
|
|
138
132
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
* Delete a flag
|
|
134
|
+
* @param {Object} flag
|
|
135
|
+
* @param {Object} options
|
|
136
|
+
* @returns {Promise<Object>} Resolves with the flag deletion
|
|
137
|
+
*/
|
|
144
138
|
delete(flag, options) {
|
|
145
139
|
if (!flag.url) {
|
|
146
140
|
return Promise.reject(new Error('`flag.url` is required'));
|
|
@@ -149,19 +143,18 @@ const Flag = WebexPlugin.extend({
|
|
|
149
143
|
const params = {
|
|
150
144
|
method: 'DELETE',
|
|
151
145
|
options,
|
|
152
|
-
uri: flag.url
|
|
146
|
+
uri: flag.url,
|
|
153
147
|
};
|
|
154
148
|
|
|
155
|
-
return this.request(params)
|
|
156
|
-
.then((res) => res.body);
|
|
149
|
+
return this.request(params).then((res) => res.body);
|
|
157
150
|
},
|
|
158
151
|
|
|
159
152
|
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
153
|
+
* UnFlags an activity
|
|
154
|
+
* @param {Object} flag
|
|
155
|
+
* @param {Object} options
|
|
156
|
+
* @returns {Promise<Object>} Resolves with the flag removal
|
|
157
|
+
*/
|
|
165
158
|
unflag(flag, options) {
|
|
166
159
|
if (!flag.url) {
|
|
167
160
|
return Promise.reject(new Error('`flag.url` is required'));
|
|
@@ -172,14 +165,12 @@ const Flag = WebexPlugin.extend({
|
|
|
172
165
|
uri: flag.url,
|
|
173
166
|
options,
|
|
174
167
|
body: {
|
|
175
|
-
state: 'unflagged'
|
|
176
|
-
}
|
|
168
|
+
state: 'unflagged',
|
|
169
|
+
},
|
|
177
170
|
};
|
|
178
171
|
|
|
179
|
-
return this.webex.request(params)
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
172
|
+
return this.webex.request(params).then((res) => res.body);
|
|
173
|
+
},
|
|
183
174
|
});
|
|
184
175
|
|
|
185
176
|
export default Flag;
|
package/src/index.js
CHANGED
|
@@ -15,91 +15,109 @@ describe('plugin-flag', function () {
|
|
|
15
15
|
describe('Flag', () => {
|
|
16
16
|
let flagConversation, mccoy, participants, spock;
|
|
17
17
|
|
|
18
|
-
beforeEach('create users', () =>
|
|
19
|
-
.then((users) => {
|
|
18
|
+
beforeEach('create users', () =>
|
|
19
|
+
testUsers.create({count: 2}).then((users) => {
|
|
20
20
|
participants = [mccoy, spock] = users;
|
|
21
21
|
spock.webex = new WebexCore({
|
|
22
22
|
credentials: {
|
|
23
|
-
authorization: users[0].token
|
|
24
|
-
}
|
|
23
|
+
authorization: users[0].token,
|
|
24
|
+
},
|
|
25
25
|
});
|
|
26
26
|
mccoy.webex = new WebexCore({
|
|
27
27
|
credentials: {
|
|
28
|
-
authorization: users[1].token
|
|
29
|
-
}
|
|
28
|
+
authorization: users[1].token,
|
|
29
|
+
},
|
|
30
30
|
});
|
|
31
|
-
})
|
|
31
|
+
})
|
|
32
|
+
);
|
|
32
33
|
|
|
33
34
|
beforeEach('connect spock to mercury', () => spock.webex.internal.mercury.connect());
|
|
34
35
|
beforeEach('connect mccoy to mercury', () => mccoy.webex.internal.mercury.connect());
|
|
35
36
|
|
|
36
|
-
afterEach(() =>
|
|
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
|
-
|
|
37
|
+
afterEach(() =>
|
|
38
|
+
Promise.all([
|
|
39
|
+
spock && spock.webex.internal.mercury.disconnect(),
|
|
40
|
+
mccoy && mccoy.webex.internal.mercury.disconnect(),
|
|
41
|
+
])
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
beforeEach('populate data', () =>
|
|
45
|
+
spock.webex.internal.conversation
|
|
46
|
+
.create({
|
|
47
|
+
displayName: 'Test Flagging Room',
|
|
48
|
+
participants,
|
|
49
|
+
})
|
|
50
|
+
.then((c) => {
|
|
51
|
+
flagConversation = c;
|
|
52
|
+
|
|
53
|
+
return mccoy.webex.internal.conversation.post(flagConversation, {
|
|
54
|
+
displayName: 'Hi Dear, How are you?',
|
|
55
|
+
});
|
|
56
|
+
})
|
|
57
|
+
.then(() =>
|
|
58
|
+
spock.webex.internal.conversation.post(flagConversation, {
|
|
59
|
+
displayName: 'Hey! I am doing well. How are you?',
|
|
60
|
+
})
|
|
61
|
+
)
|
|
62
|
+
.then(() =>
|
|
63
|
+
mccoy.webex.internal.conversation.post(flagConversation, {
|
|
64
|
+
displayName: 'I am also doing well. Are you in for the party?',
|
|
65
|
+
})
|
|
66
|
+
)
|
|
67
|
+
.then(() =>
|
|
68
|
+
spock.webex.internal.conversation.post(flagConversation, {
|
|
69
|
+
displayName: 'Yes, I am in.',
|
|
70
|
+
})
|
|
71
|
+
)
|
|
72
|
+
.then(() => {
|
|
73
|
+
assert.isDefined(flagConversation);
|
|
74
|
+
const params = {
|
|
75
|
+
activitiesLimit: 30,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return spock.webex.internal.conversation.get(flagConversation, params);
|
|
79
|
+
})
|
|
80
|
+
.then((conversation) => {
|
|
81
|
+
// Removes the "create" activity.
|
|
82
|
+
conversation.activities.items.shift();
|
|
83
|
+
const comments = map(conversation.activities.items, 'object.displayName');
|
|
84
|
+
|
|
85
|
+
assert.lengthOf(comments, 4);
|
|
86
|
+
assert.equal(comments[0], 'Hi Dear, How are you?');
|
|
87
|
+
assert.equal(comments[1], 'Hey! I am doing well. How are you?');
|
|
88
|
+
assert.equal(comments[2], 'I am also doing well. Are you in for the party?');
|
|
89
|
+
assert.equal(comments[3], 'Yes, I am in.');
|
|
90
|
+
flagConversation = conversation;
|
|
91
|
+
})
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
afterEach(() =>
|
|
95
|
+
spock.webex.internal.flag
|
|
96
|
+
.list()
|
|
97
|
+
.then((flags) =>
|
|
98
|
+
Promise.all(
|
|
99
|
+
flags.map((flag) =>
|
|
100
|
+
spock.webex.internal.flag.delete(flag).catch((reason) => console.warn(reason))
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
);
|
|
86
105
|
|
|
87
106
|
describe('#create()', () => {
|
|
88
107
|
it('flags the activity', () => {
|
|
89
108
|
const flaggedActivity1 = flagConversation.activities.items[1];
|
|
90
109
|
|
|
91
|
-
return spock.webex.internal.flag.create(flaggedActivity1)
|
|
92
|
-
.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
110
|
+
return spock.webex.internal.flag.create(flaggedActivity1).then((flagResponse1) => {
|
|
111
|
+
assert.equal(flagResponse1.state, 'flagged');
|
|
112
|
+
assert.equal(flagResponse1['flag-item'], flaggedActivity1.url);
|
|
113
|
+
assert.equal(flagResponse1['conversation-url'], flaggedActivity1.target.url);
|
|
114
|
+
});
|
|
97
115
|
});
|
|
98
116
|
});
|
|
99
117
|
|
|
100
118
|
describe('#list()', () => {
|
|
101
|
-
it('fetches the flag list', () =>
|
|
102
|
-
.then((flagList) => {
|
|
119
|
+
it('fetches the flag list', () =>
|
|
120
|
+
spock.webex.internal.flag.list().then((flagList) => {
|
|
103
121
|
assert.isArray(flagList);
|
|
104
122
|
assert.lengthOf(flagList, 0);
|
|
105
123
|
}));
|
|
@@ -109,21 +127,19 @@ describe('plugin-flag', function () {
|
|
|
109
127
|
it('maps flags to activity', () => {
|
|
110
128
|
const flaggedActivity1 = flagConversation.activities.items[1];
|
|
111
129
|
|
|
112
|
-
return spock.webex.internal.flag.create(flaggedActivity1)
|
|
113
|
-
.
|
|
114
|
-
|
|
115
|
-
const flags = [];
|
|
130
|
+
return spock.webex.internal.flag.create(flaggedActivity1).then((flagResponse1) => {
|
|
131
|
+
assert.equal(flagResponse1.state, 'flagged');
|
|
132
|
+
const flags = [];
|
|
116
133
|
|
|
117
|
-
|
|
134
|
+
flags.push(flagResponse1);
|
|
118
135
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const activity = activities[0];
|
|
136
|
+
return spock.webex.internal.flag.mapToActivities(flags).then((activities) => {
|
|
137
|
+
const activity = activities[0];
|
|
122
138
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
139
|
+
assert.equal(activity.object.displayName, 'Hey! I am doing well. How are you?');
|
|
140
|
+
assert.isDefined(find(activities, {url: flagResponse1['flag-item']}));
|
|
126
141
|
});
|
|
142
|
+
});
|
|
127
143
|
});
|
|
128
144
|
});
|
|
129
145
|
|
|
@@ -131,7 +147,8 @@ describe('plugin-flag', function () {
|
|
|
131
147
|
it('removes the flag from activity', () => {
|
|
132
148
|
const flaggedActivity1 = flagConversation.activities.items[1];
|
|
133
149
|
|
|
134
|
-
return spock.webex.internal.flag
|
|
150
|
+
return spock.webex.internal.flag
|
|
151
|
+
.create(flaggedActivity1)
|
|
135
152
|
.then((flagResponse1) => {
|
|
136
153
|
assert.equal(flagResponse1.state, 'flagged');
|
|
137
154
|
|
|
@@ -149,7 +166,8 @@ describe('plugin-flag', function () {
|
|
|
149
166
|
it('archives the flag for an activity', () => {
|
|
150
167
|
const flaggedActivity1 = flagConversation.activities.items[1];
|
|
151
168
|
|
|
152
|
-
return spock.webex.internal.flag
|
|
169
|
+
return spock.webex.internal.flag
|
|
170
|
+
.create(flaggedActivity1)
|
|
153
171
|
.then((flagResponse1) => {
|
|
154
172
|
assert.equal(flagResponse1.state, 'flagged');
|
|
155
173
|
|
|
@@ -163,7 +181,8 @@ describe('plugin-flag', function () {
|
|
|
163
181
|
it('unflag the flag for an activity', () => {
|
|
164
182
|
const flaggedActivity1 = flagConversation.activities.items[1];
|
|
165
183
|
|
|
166
|
-
return spock.webex.internal.flag
|
|
184
|
+
return spock.webex.internal.flag
|
|
185
|
+
.create(flaggedActivity1)
|
|
167
186
|
.then((flagResponse1) => {
|
|
168
187
|
assert.equal(flagResponse1.state, 'flagged');
|
|
169
188
|
|
package/test/unit/spec/flag.js
CHANGED
|
@@ -13,25 +13,29 @@ describe('plugin-flag', () => {
|
|
|
13
13
|
beforeEach(() => {
|
|
14
14
|
webex = new MockWebex({
|
|
15
15
|
children: {
|
|
16
|
-
flag: Flag
|
|
17
|
-
}
|
|
16
|
+
flag: Flag,
|
|
17
|
+
},
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
describe('#flag()', () => {
|
|
22
|
-
it('requires an activity URL', () =>
|
|
22
|
+
it('requires an activity URL', () =>
|
|
23
|
+
assert.isRejected(webex.internal.flag.create({}, {}), /`activity.url` is required/));
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
describe('#unflag()', () => {
|
|
26
|
-
it('requires a Flag Id', () =>
|
|
27
|
+
it('requires a Flag Id', () =>
|
|
28
|
+
assert.isRejected(webex.internal.flag.unflag({}, {}), /`flag.url` is required/));
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
describe('#archive()', () => {
|
|
30
|
-
it('requires a Flag Id', () =>
|
|
32
|
+
it('requires a Flag Id', () =>
|
|
33
|
+
assert.isRejected(webex.internal.flag.archive({}, {}), /`flag.url` is required/));
|
|
31
34
|
});
|
|
32
35
|
|
|
33
36
|
describe('#remove()', () => {
|
|
34
|
-
it('requires a Flag Id', () =>
|
|
37
|
+
it('requires a Flag Id', () =>
|
|
38
|
+
assert.isRejected(webex.internal.flag.delete({}, {}), /`flag.url` is required/));
|
|
35
39
|
});
|
|
36
40
|
});
|
|
37
41
|
});
|