@webex/internal-plugin-presence 3.4.0-next.2 → 3.4.0-next.4
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/dist/presence.js +2 -1
- package/dist/presence.js.map +1 -1
- package/package.json +12 -12
- package/src/presence.js +1 -0
- package/test/integration/spec/presence.js +2 -0
- package/test/unit/spec/presence.js +23 -0
package/dist/presence.js
CHANGED
|
@@ -232,6 +232,7 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
232
232
|
body: {
|
|
233
233
|
subject: this.webex.internal.device.userId,
|
|
234
234
|
eventType: status,
|
|
235
|
+
label: this.webex.internal.device.userId,
|
|
235
236
|
ttl: ttl
|
|
236
237
|
}
|
|
237
238
|
}).then(function (response) {
|
|
@@ -254,7 +255,7 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
254
255
|
dequeue: function dequeue(id) {
|
|
255
256
|
return this.worker.dequeue(id);
|
|
256
257
|
},
|
|
257
|
-
version: "3.4.0-next.
|
|
258
|
+
version: "3.4.0-next.4"
|
|
258
259
|
});
|
|
259
260
|
var _default2 = exports.default = Presence;
|
|
260
261
|
//# sourceMappingURL=presence.js.map
|
package/dist/presence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","_webexCore","_presenceBatcher","_interopRequireDefault","_presenceWorker","defaultSubscriptionTtl","USER","USER_PRESENCE_ENABLED","Presence","WebexPlugin","extend","namespace","children","batcher","PresenceBatcher","session","worker","default","_default","PresenceWorker","type","initialize","_this","webex","once","config","initializeWorker","emitEvent","event","payload","trigger","enable","internal","feature","setFeature","then","response","value","disable","isEnabled","getFeature","get","personId","_promise","reject","Error","request","method","service","resource","concat","body","list","personIds","_this2","_isArray","all","map","id","presences","statusList","subscribe","_this3","subscriptionTtl","arguments","length","undefined","subjects","batches","batchLimit","i","push","slice","ids","api","includeStatus","responses","idBatches","_ref","apply","_toConsumableArray2","unsubscribe","setStatus","status","ttl","subject","device","userId","eventType","enqueue","dequeue","version","_default2","exports"],"sources":["presence.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport '@webex/internal-plugin-device';\n\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport PresenceBatcher from './presence-batcher';\nimport PresenceWorker from './presence-worker';\n\nconst defaultSubscriptionTtl = 600;\nconst USER = 'user';\nconst USER_PRESENCE_ENABLED = 'user-presence-enabled';\n\n/**\n * @class\n * @extends WebexPlugin\n */\nconst Presence = WebexPlugin.extend({\n namespace: 'Presence',\n\n children: {\n batcher: PresenceBatcher,\n },\n\n session: {\n worker: {\n default() {\n return new PresenceWorker();\n },\n type: 'any',\n },\n },\n\n /**\n * Initialize the presence worker for client\n * @returns {undefined}\n */\n initialize() {\n this.webex.once('ready', () => {\n if (this.config.initializeWorker) {\n this.worker.initialize(this.webex);\n }\n });\n },\n\n /**\n * Trigger an event.\n * @param {string} event\n * @param {string} payload\n * @returns {undefined}\n */\n emitEvent(event, payload) {\n if (payload.type && payload.payload) {\n this.trigger(event, payload);\n }\n },\n\n /**\n * Enables presence feature\n * @returns {Promise<boolean>} resolves with true, if successful\n */\n enable() {\n return this.webex.internal.feature\n .setFeature(USER, USER_PRESENCE_ENABLED, true)\n .then((response) => response.value);\n },\n\n /**\n * Disables presence feature\n * @returns {Promise<boolean>} resolves with false, if successful\n */\n disable() {\n return this.webex.internal.feature\n .setFeature(USER, USER_PRESENCE_ENABLED, false)\n .then((response) => response.value);\n },\n\n /**\n * Returns true if presence is enabled, false otherwise\n * @returns {Promise<boolean>} resolves with true if presence is enabled\n */\n isEnabled() {\n return this.webex.internal.feature.getFeature(USER, USER_PRESENCE_ENABLED);\n },\n\n /**\n * The status object\n * @typedef {Object} PresenceStatusObject\n * @property {string} url: Public resource identifier for presence\n * @property {string} subject: User ID for the user the returned composed presence represents\n * @property {string} status: Current composed presence state\n * @property {string} statusTime: DateTime in RFC3339 format that the current status began\n * @property {string} lastActive: DateTime in RFC3339 format that the service last saw activity from the user.\n * @property {string} expires: DEPRECATED - DateTime in RFC3339 format that represents when the current\n * status will expire. Will not exist if expiresTTL is -1.\n * @property {Number} expiresTTL: TTL in seconds until the status will expire. If TTL is -1 the current\n * status has no known expiration.\n * @property {string} expiresTime: DateTime in RFC3339 format that the current status will expire. Missing\n * field means no known expiration.\n * @property {Object} vectorCounters: Used for packet ordering and tracking.\n * @property {Boolean} suppressNotifications: Indicates if notification suppression is recommended for this status.\n * @property {string} lastSeenDeviceUrl: Resource Identifier of the last device to post presence activity for\n * this user.\n */\n\n /**\n * Gets the current presence status of a given person id\n * @param {string} personId\n * @returns {Promise<PresenceStatusObject>} resolves with status object of person\n */\n get(personId) {\n if (!personId) {\n return Promise.reject(new Error('A person id is required'));\n }\n\n return this.webex\n .request({\n method: 'GET',\n service: 'apheleia',\n resource: `compositions?userId=${personId}`,\n })\n .then((response) => response.body);\n },\n\n /**\n * @typedef {Object} PresenceStatusesObject\n * @property {Array.<PresenceStatusObject>} statusList\n */\n /**\n * Gets the current presence statuses of an array of people ids\n * @param {Array} personIds\n * @returns {Promise<PresenceStatusesObject>} resolves with an object with key of `statusList` array\n */\n list(personIds) {\n if (!personIds || !Array.isArray(personIds)) {\n return Promise.reject(new Error('An array of person ids is required'));\n }\n\n return Promise.all(personIds.map((id) => this.batcher.request(id))).then((presences) => ({\n statusList: presences,\n }));\n },\n\n /**\n * Subscribes to a person's presence status updates\n * Updates are sent via mercury events `apheleia.subscription_update`\n * @param {string | Array} personIds\n * @param {number} subscriptionTtl - Requested length of subscriptions in seconds.\n * @returns {Promise}\n */\n subscribe(personIds, subscriptionTtl = defaultSubscriptionTtl) {\n let subjects;\n const batches = [];\n const batchLimit = 50;\n\n if (!personIds) {\n return Promise.reject(new Error('A person id is required'));\n }\n if (Array.isArray(personIds)) {\n subjects = personIds;\n } else {\n subjects = [personIds];\n }\n // Limit batches to 50 ids per request\n for (let i = 0; i < subjects.length; i += batchLimit) {\n batches.push(subjects.slice(i, i + batchLimit));\n }\n\n return Promise.all(\n batches.map((ids) =>\n this.webex\n .request({\n method: 'POST',\n api: 'apheleia',\n resource: 'subscriptions',\n body: {\n subjects: ids,\n subscriptionTtl,\n includeStatus: true,\n },\n })\n .then((response) => response.body.responses)\n )\n ).then((idBatches) => ({responses: [].concat(...idBatches)}));\n },\n\n /**\n * Unsubscribes from a person or group of people's presence subscription\n * @param {string | Array} personIds\n * @returns {Promise}\n */\n unsubscribe(personIds) {\n let subjects;\n\n if (!personIds) {\n return Promise.reject(new Error('A person id is required'));\n }\n if (Array.isArray(personIds)) {\n subjects = personIds;\n } else {\n subjects = [personIds];\n }\n\n return this.webex.request({\n method: 'POST',\n api: 'apheleia',\n resource: 'subscriptions',\n body: {\n subjects,\n subscriptionTtl: 0,\n includeStatus: true,\n },\n });\n },\n\n /**\n * Sets the status of the current user\n * @param {string} status - active | inactive | ooo | dnd\n * @param {number} ttl - Time To Live for the event in seconds.\n * @returns {Promise}\n */\n setStatus(status, ttl) {\n if (!status) {\n return Promise.reject(new Error('A status is required'));\n }\n\n return this.webex\n .request({\n method: 'POST',\n api: 'apheleia',\n resource: 'events',\n body: {\n subject: this.webex.internal.device.userId,\n eventType: status,\n ttl,\n },\n })\n .then((response) => response.body);\n },\n\n /**\n * Retrieves and subscribes to a user's presence.\n * @param {string} id\n * @returns {undefined}\n */\n enqueue(id) {\n return this.worker.enqueue(id);\n },\n\n /**\n * Retract from subscribing to a user's presence.\n * @param {string} id\n * @returns {undefined}\n */\n dequeue(id) {\n return this.worker.dequeue(id);\n },\n});\n\nexport default Presence;\n"],"mappings":";;;;;;;;;;;AAIAA,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;;AASA,IAAMK,sBAAsB,GAAG,GAAG;AAClC,IAAMC,IAAI,GAAG,M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AAC;IAC1D;IAEA,OAAO,IAAI,CAACtB,KAAK,CACduB,OAAO,CAAC;MACPC,MAAM,EAAE,MAAM;MACd2B,GAAG,EAAE,UAAU;MACfzB,QAAQ,EAAE,QAAQ;MAClBE,IAAI,EAAE;QACJkC,OAAO,EAAE,IAAI,CAAC9D,KAAK,CAACS,QAAQ,CAACsD,MAAM,CAACC,MAAM;QAC1CC,SAAS,EAAEL,MAAM;QACjBC,GAAG,EAAHA;MACF;IACF,CAAC,CAAC,CACDjD,IAAI,CAAC,UAACC,QAAQ;MAAA,OAAKA,QAAQ,CAACe,IAAI;IAAA,EAAC;EACtC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEsC,OAAO,WAAAA,QAAC/B,EAAE,EAAE;IACV,OAAO,IAAI,CAAC1C,MAAM,CAACyE,OAAO,CAAC/B,EAAE,CAAC;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEgC,OAAO,WAAAA,QAAChC,EAAE,EAAE;IACV,OAAO,IAAI,CAAC1C,MAAM,CAAC0E,OAAO,CAAChC,EAAE,CAAC;EAChC,CAAC;EAAAiC,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,SAAA,GAAAC,OAAA,CAAA5E,OAAA,GAEYT,QAAQ"}
|
|
1
|
+
{"version":3,"names":["require","_webexCore","_presenceBatcher","_interopRequireDefault","_presenceWorker","defaultSubscriptionTtl","USER","USER_PRESENCE_ENABLED","Presence","WebexPlugin","extend","namespace","children","batcher","PresenceBatcher","session","worker","default","_default","PresenceWorker","type","initialize","_this","webex","once","config","initializeWorker","emitEvent","event","payload","trigger","enable","internal","feature","setFeature","then","response","value","disable","isEnabled","getFeature","get","personId","_promise","reject","Error","request","method","service","resource","concat","body","list","personIds","_this2","_isArray","all","map","id","presences","statusList","subscribe","_this3","subscriptionTtl","arguments","length","undefined","subjects","batches","batchLimit","i","push","slice","ids","api","includeStatus","responses","idBatches","_ref","apply","_toConsumableArray2","unsubscribe","setStatus","status","ttl","subject","device","userId","eventType","label","enqueue","dequeue","version","_default2","exports"],"sources":["presence.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport '@webex/internal-plugin-device';\n\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport PresenceBatcher from './presence-batcher';\nimport PresenceWorker from './presence-worker';\n\nconst defaultSubscriptionTtl = 600;\nconst USER = 'user';\nconst USER_PRESENCE_ENABLED = 'user-presence-enabled';\n\n/**\n * @class\n * @extends WebexPlugin\n */\nconst Presence = WebexPlugin.extend({\n namespace: 'Presence',\n\n children: {\n batcher: PresenceBatcher,\n },\n\n session: {\n worker: {\n default() {\n return new PresenceWorker();\n },\n type: 'any',\n },\n },\n\n /**\n * Initialize the presence worker for client\n * @returns {undefined}\n */\n initialize() {\n this.webex.once('ready', () => {\n if (this.config.initializeWorker) {\n this.worker.initialize(this.webex);\n }\n });\n },\n\n /**\n * Trigger an event.\n * @param {string} event\n * @param {string} payload\n * @returns {undefined}\n */\n emitEvent(event, payload) {\n if (payload.type && payload.payload) {\n this.trigger(event, payload);\n }\n },\n\n /**\n * Enables presence feature\n * @returns {Promise<boolean>} resolves with true, if successful\n */\n enable() {\n return this.webex.internal.feature\n .setFeature(USER, USER_PRESENCE_ENABLED, true)\n .then((response) => response.value);\n },\n\n /**\n * Disables presence feature\n * @returns {Promise<boolean>} resolves with false, if successful\n */\n disable() {\n return this.webex.internal.feature\n .setFeature(USER, USER_PRESENCE_ENABLED, false)\n .then((response) => response.value);\n },\n\n /**\n * Returns true if presence is enabled, false otherwise\n * @returns {Promise<boolean>} resolves with true if presence is enabled\n */\n isEnabled() {\n return this.webex.internal.feature.getFeature(USER, USER_PRESENCE_ENABLED);\n },\n\n /**\n * The status object\n * @typedef {Object} PresenceStatusObject\n * @property {string} url: Public resource identifier for presence\n * @property {string} subject: User ID for the user the returned composed presence represents\n * @property {string} status: Current composed presence state\n * @property {string} statusTime: DateTime in RFC3339 format that the current status began\n * @property {string} lastActive: DateTime in RFC3339 format that the service last saw activity from the user.\n * @property {string} expires: DEPRECATED - DateTime in RFC3339 format that represents when the current\n * status will expire. Will not exist if expiresTTL is -1.\n * @property {Number} expiresTTL: TTL in seconds until the status will expire. If TTL is -1 the current\n * status has no known expiration.\n * @property {string} expiresTime: DateTime in RFC3339 format that the current status will expire. Missing\n * field means no known expiration.\n * @property {Object} vectorCounters: Used for packet ordering and tracking.\n * @property {Boolean} suppressNotifications: Indicates if notification suppression is recommended for this status.\n * @property {string} lastSeenDeviceUrl: Resource Identifier of the last device to post presence activity for\n * this user.\n */\n\n /**\n * Gets the current presence status of a given person id\n * @param {string} personId\n * @returns {Promise<PresenceStatusObject>} resolves with status object of person\n */\n get(personId) {\n if (!personId) {\n return Promise.reject(new Error('A person id is required'));\n }\n\n return this.webex\n .request({\n method: 'GET',\n service: 'apheleia',\n resource: `compositions?userId=${personId}`,\n })\n .then((response) => response.body);\n },\n\n /**\n * @typedef {Object} PresenceStatusesObject\n * @property {Array.<PresenceStatusObject>} statusList\n */\n /**\n * Gets the current presence statuses of an array of people ids\n * @param {Array} personIds\n * @returns {Promise<PresenceStatusesObject>} resolves with an object with key of `statusList` array\n */\n list(personIds) {\n if (!personIds || !Array.isArray(personIds)) {\n return Promise.reject(new Error('An array of person ids is required'));\n }\n\n return Promise.all(personIds.map((id) => this.batcher.request(id))).then((presences) => ({\n statusList: presences,\n }));\n },\n\n /**\n * Subscribes to a person's presence status updates\n * Updates are sent via mercury events `apheleia.subscription_update`\n * @param {string | Array} personIds\n * @param {number} subscriptionTtl - Requested length of subscriptions in seconds.\n * @returns {Promise}\n */\n subscribe(personIds, subscriptionTtl = defaultSubscriptionTtl) {\n let subjects;\n const batches = [];\n const batchLimit = 50;\n\n if (!personIds) {\n return Promise.reject(new Error('A person id is required'));\n }\n if (Array.isArray(personIds)) {\n subjects = personIds;\n } else {\n subjects = [personIds];\n }\n // Limit batches to 50 ids per request\n for (let i = 0; i < subjects.length; i += batchLimit) {\n batches.push(subjects.slice(i, i + batchLimit));\n }\n\n return Promise.all(\n batches.map((ids) =>\n this.webex\n .request({\n method: 'POST',\n api: 'apheleia',\n resource: 'subscriptions',\n body: {\n subjects: ids,\n subscriptionTtl,\n includeStatus: true,\n },\n })\n .then((response) => response.body.responses)\n )\n ).then((idBatches) => ({responses: [].concat(...idBatches)}));\n },\n\n /**\n * Unsubscribes from a person or group of people's presence subscription\n * @param {string | Array} personIds\n * @returns {Promise}\n */\n unsubscribe(personIds) {\n let subjects;\n\n if (!personIds) {\n return Promise.reject(new Error('A person id is required'));\n }\n if (Array.isArray(personIds)) {\n subjects = personIds;\n } else {\n subjects = [personIds];\n }\n\n return this.webex.request({\n method: 'POST',\n api: 'apheleia',\n resource: 'subscriptions',\n body: {\n subjects,\n subscriptionTtl: 0,\n includeStatus: true,\n },\n });\n },\n\n /**\n * Sets the status of the current user\n * @param {string} status - active | inactive | ooo | dnd\n * @param {number} ttl - Time To Live for the event in seconds.\n * @returns {Promise}\n */\n setStatus(status, ttl) {\n if (!status) {\n return Promise.reject(new Error('A status is required'));\n }\n\n return this.webex\n .request({\n method: 'POST',\n api: 'apheleia',\n resource: 'events',\n body: {\n subject: this.webex.internal.device.userId,\n eventType: status,\n label: this.webex.internal.device.userId,\n ttl,\n },\n })\n .then((response) => response.body);\n },\n\n /**\n * Retrieves and subscribes to a user's presence.\n * @param {string} id\n * @returns {undefined}\n */\n enqueue(id) {\n return this.worker.enqueue(id);\n },\n\n /**\n * Retract from subscribing to a user's presence.\n * @param {string} id\n * @returns {undefined}\n */\n dequeue(id) {\n return this.worker.dequeue(id);\n },\n});\n\nexport default Presence;\n"],"mappings":";;;;;;;;;;;AAIAA,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;;AASA,IAAMK,sBAAsB,GAAG,GAAG;AAClC,IAAMC,IAAI,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CAAC,CAAC;IAC1D;IAEA,OAAO,IAAI,CAACtB,KAAK,CACduB,OAAO,CAAC;MACPC,MAAM,EAAE,MAAM;MACd2B,GAAG,EAAE,UAAU;MACfzB,QAAQ,EAAE,QAAQ;MAClBE,IAAI,EAAE;QACJkC,OAAO,EAAE,IAAI,CAAC9D,KAAK,CAACS,QAAQ,CAACsD,MAAM,CAACC,MAAM;QAC1CC,SAAS,EAAEL,MAAM;QACjBM,KAAK,EAAE,IAAI,CAAClE,KAAK,CAACS,QAAQ,CAACsD,MAAM,CAACC,MAAM;QACxCH,GAAG,EAAHA;MACF;IACF,CAAC,CAAC,CACDjD,IAAI,CAAC,UAACC,QAAQ;MAAA,OAAKA,QAAQ,CAACe,IAAI;IAAA,EAAC;EACtC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEuC,OAAO,WAAAA,QAAChC,EAAE,EAAE;IACV,OAAO,IAAI,CAAC1C,MAAM,CAAC0E,OAAO,CAAChC,EAAE,CAAC;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEiC,OAAO,WAAAA,QAACjC,EAAE,EAAE;IACV,OAAO,IAAI,CAAC1C,MAAM,CAAC2E,OAAO,CAACjC,EAAE,CAAC;EAChC,CAAC;EAAAkC,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,SAAA,GAAAC,OAAA,CAAA7E,OAAA,GAEYT,QAAQ"}
|
package/package.json
CHANGED
|
@@ -24,22 +24,22 @@
|
|
|
24
24
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
25
25
|
"@webex/jest-config-legacy": "0.0.0",
|
|
26
26
|
"@webex/legacy-tools": "0.0.0",
|
|
27
|
-
"@webex/test-helper-chai": "3.4.0-next.
|
|
28
|
-
"@webex/test-helper-mocha": "3.4.0-next.
|
|
29
|
-
"@webex/test-helper-mock-webex": "3.4.0-next.
|
|
30
|
-
"@webex/test-helper-test-users": "3.4.0-next.
|
|
27
|
+
"@webex/test-helper-chai": "3.4.0-next.3",
|
|
28
|
+
"@webex/test-helper-mocha": "3.4.0-next.3",
|
|
29
|
+
"@webex/test-helper-mock-webex": "3.4.0-next.3",
|
|
30
|
+
"@webex/test-helper-test-users": "3.4.0-next.3",
|
|
31
31
|
"eslint": "^8.24.0",
|
|
32
32
|
"prettier": "^2.7.1",
|
|
33
33
|
"sinon": "^9.2.4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@webex/internal-plugin-device": "3.4.0-next.
|
|
37
|
-
"@webex/internal-plugin-mercury": "3.4.0-next.
|
|
38
|
-
"@webex/test-helper-chai": "3.4.0-next.
|
|
39
|
-
"@webex/test-helper-mocha": "3.4.0-next.
|
|
40
|
-
"@webex/test-helper-mock-webex": "3.4.0-next.
|
|
41
|
-
"@webex/test-helper-test-users": "3.4.0-next.
|
|
42
|
-
"@webex/webex-core": "3.4.0-next.
|
|
36
|
+
"@webex/internal-plugin-device": "3.4.0-next.3",
|
|
37
|
+
"@webex/internal-plugin-mercury": "3.4.0-next.3",
|
|
38
|
+
"@webex/test-helper-chai": "3.4.0-next.3",
|
|
39
|
+
"@webex/test-helper-mocha": "3.4.0-next.3",
|
|
40
|
+
"@webex/test-helper-mock-webex": "3.4.0-next.3",
|
|
41
|
+
"@webex/test-helper-test-users": "3.4.0-next.3",
|
|
42
|
+
"@webex/webex-core": "3.4.0-next.3",
|
|
43
43
|
"lodash": "^4.17.21"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"test:style": "eslint ./src/**/*.*",
|
|
52
52
|
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
53
53
|
},
|
|
54
|
-
"version": "3.4.0-next.
|
|
54
|
+
"version": "3.4.0-next.4"
|
|
55
55
|
}
|
package/src/presence.js
CHANGED
|
@@ -206,8 +206,10 @@ describe.skip('plugin-presence', function () {
|
|
|
206
206
|
spock.webex.internal.presence.setStatus('dnd', 1500).then((statusResponse) => {
|
|
207
207
|
assert.property(statusResponse, 'subject');
|
|
208
208
|
assert.property(statusResponse, 'status');
|
|
209
|
+
assert.property(statusResponse, 'label');
|
|
209
210
|
assert.equal(statusResponse.subject, spock.id);
|
|
210
211
|
assert.equal(statusResponse.status, 'dnd');
|
|
212
|
+
assert.equal(statusResponse.label, spock.id);
|
|
211
213
|
}));
|
|
212
214
|
});
|
|
213
215
|
});
|
|
@@ -64,6 +64,29 @@ describe.skip('plugin-presence', () => {
|
|
|
64
64
|
describe('#setStatus()', () => {
|
|
65
65
|
it('requires a status', () =>
|
|
66
66
|
assert.isRejected(webex.internal.presence.setStatus(), /A status is required/));
|
|
67
|
+
|
|
68
|
+
it('passes a label to the API', () => {
|
|
69
|
+
const testGuid = 'test-guid';
|
|
70
|
+
|
|
71
|
+
webex.internal.device.userId = testGuid;
|
|
72
|
+
|
|
73
|
+
webex.request = function (options) {
|
|
74
|
+
return Promise.resolve({
|
|
75
|
+
statusCode: 204,
|
|
76
|
+
body: [],
|
|
77
|
+
options,
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
sinon.spy(webex, 'request');
|
|
81
|
+
|
|
82
|
+
webex.internal.presence.setStatus('dnd');
|
|
83
|
+
|
|
84
|
+
assert.calledOnce(webex.request);
|
|
85
|
+
|
|
86
|
+
const request = webex.request.getCall(0);
|
|
87
|
+
|
|
88
|
+
assert.equal(request.args[0].body.label, testGuid);
|
|
89
|
+
});
|
|
67
90
|
});
|
|
68
91
|
});
|
|
69
92
|
});
|