@webex/internal-plugin-team 2.59.1 → 2.59.3-next.1

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.
@@ -1,153 +1,153 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- /* eslint-disable no-underscore-dangle */
6
- import {assert} from '@webex/test-helper-chai';
7
- import MockWebex from '@webex/test-helper-mock-webex';
8
- import sinon from 'sinon';
9
- import Team from '@webex/internal-plugin-team';
10
- import User from '@webex/internal-plugin-user';
11
- import uuid from 'uuid';
12
-
13
- const TEAM_URL = 'https://example.com/team';
14
- const TEAM_DISPLAY_NAME = 'test';
15
-
16
- describe('plugin-team', () => {
17
- describe('Team', () => {
18
- let webex;
19
-
20
- beforeEach(() => {
21
- webex = new MockWebex({
22
- children: {
23
- team: Team,
24
- user: User,
25
- },
26
- });
27
-
28
- webex.internal.user.recordUUID = sinon.spy();
29
- });
30
-
31
- describe('#create()', () => {
32
- it('requires a displayName', () =>
33
- assert.isRejected(webex.internal.team.create({}), /`params.displayName` is required/));
34
-
35
- it('requires a participants attribute', () =>
36
- assert.isRejected(
37
- webex.internal.team.create({displayName: 'test'}),
38
- /`params.participants` is required/
39
- ));
40
-
41
- it('requires a participants array', () =>
42
- assert.isRejected(
43
- webex.internal.team.create({displayName: 'test', participants: []}),
44
- /`params.participants` is required/
45
- ));
46
- });
47
-
48
- describe('#createConversation()', () => {
49
- const url = TEAM_URL;
50
- const displayName = TEAM_DISPLAY_NAME;
51
-
52
- it('requires a URL', () =>
53
- assert.isRejected(
54
- webex.internal.team.createConversation({}, {}),
55
- /`team.url` is required/
56
- ));
57
-
58
- it('requires a displayName', () =>
59
- assert.isRejected(
60
- webex.internal.team.createConversation({url}, {}),
61
- /`params.displayName` is required/
62
- ));
63
-
64
- it('requires a team object with a general conversation', () =>
65
- assert.isRejected(
66
- webex.internal.team.createConversation({url}, {displayName}),
67
- /`team.generalConversationUuid` must be present/
68
- ));
69
- });
70
-
71
- describe('#get()', () => {
72
- it('requires a team url', () =>
73
- assert.isRejected(webex.internal.team.get({}), /`team.url` is required/));
74
- });
75
-
76
- describe('#listConversations()', () => {
77
- it('requires a team url', () =>
78
- assert.isRejected(webex.internal.team.listConversations({}), /`team.url` is required/));
79
- });
80
-
81
- describe('#prepareTeamConversation()', () => {
82
- it('requires a KRO', () =>
83
- assert.isRejected(
84
- webex.internal.team._prepareTeamConversation({}),
85
- /Team general conversation must have a KRO/
86
- ));
87
- });
88
-
89
- describe('#recordUUIDs', () => {
90
- it('resolves if there are no teamMembers', () =>
91
- webex.internal.team
92
- ._recordUUIDs({})
93
- .then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0)));
94
-
95
- it("resolves if there isn't teamMembers.items", () =>
96
- webex.internal.team
97
- ._recordUUIDs({teamMembers: {}})
98
- .then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0)));
99
-
100
- it('resolves if there is a LYRA_SPACE user', () => {
101
- const user = {
102
- id: uuid.v4(),
103
- type: 'LYRA_SPACE',
104
- };
105
-
106
- return webex.internal.team
107
- ._recordUUIDs({teamMembers: {[user.id]: user}})
108
- .then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0));
109
- });
110
- });
111
-
112
- describe('#joinConversation', () => {
113
- const conversation = {kmsResourceObjectUrl: 'convoKroUrl', id: 'convoId'};
114
- const team = {url: 'teamUrl'};
115
- const userId = 'userId';
116
-
117
- beforeEach(() => {
118
- webex.credentials.supertoken = {access_token: 'fake_token'};
119
- });
120
-
121
- it('requires userId to joinConversation', () =>
122
- assert.isRejected(webex.internal.team.joinConversation(team, conversation), /`userId` is required/));
123
-
124
- it('makes POST to convo service with correct body kmsMessage', () => {
125
- webex.credentials.supertoken = {access_token: 'fake_token'}
126
- return webex.internal.team.joinConversation(team, conversation, userId).then(() => {
127
- assert.calledWith(
128
- webex.request,
129
- sinon.match({
130
- method: 'POST',
131
- uri: `${team.url}/conversations/${conversation.id}/participants`,
132
- body: {
133
- kmsMessage: {
134
- client: {
135
- clientId: webex.internal.device.url,
136
- credential: {
137
- bearer: webex.credentials.supertoken.access_token,
138
- userId,
139
- },
140
- },
141
- method: 'create',
142
- resourceUri: conversation.kmsResourceObjectUrl,
143
- uri: '/authorizations',
144
- userIds: [userId],
145
- }
146
- },
147
- })
148
- );
149
- })
150
- })
151
- })
152
- });
153
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ /* eslint-disable no-underscore-dangle */
6
+ import {assert} from '@webex/test-helper-chai';
7
+ import MockWebex from '@webex/test-helper-mock-webex';
8
+ import sinon from 'sinon';
9
+ import Team from '@webex/internal-plugin-team';
10
+ import User from '@webex/internal-plugin-user';
11
+ import uuid from 'uuid';
12
+
13
+ const TEAM_URL = 'https://example.com/team';
14
+ const TEAM_DISPLAY_NAME = 'test';
15
+
16
+ describe('plugin-team', () => {
17
+ describe('Team', () => {
18
+ let webex;
19
+
20
+ beforeEach(() => {
21
+ webex = new MockWebex({
22
+ children: {
23
+ team: Team,
24
+ user: User,
25
+ },
26
+ });
27
+
28
+ webex.internal.user.recordUUID = sinon.spy();
29
+ });
30
+
31
+ describe('#create()', () => {
32
+ it('requires a displayName', () =>
33
+ assert.isRejected(webex.internal.team.create({}), /`params.displayName` is required/));
34
+
35
+ it('requires a participants attribute', () =>
36
+ assert.isRejected(
37
+ webex.internal.team.create({displayName: 'test'}),
38
+ /`params.participants` is required/
39
+ ));
40
+
41
+ it('requires a participants array', () =>
42
+ assert.isRejected(
43
+ webex.internal.team.create({displayName: 'test', participants: []}),
44
+ /`params.participants` is required/
45
+ ));
46
+ });
47
+
48
+ describe('#createConversation()', () => {
49
+ const url = TEAM_URL;
50
+ const displayName = TEAM_DISPLAY_NAME;
51
+
52
+ it('requires a URL', () =>
53
+ assert.isRejected(
54
+ webex.internal.team.createConversation({}, {}),
55
+ /`team.url` is required/
56
+ ));
57
+
58
+ it('requires a displayName', () =>
59
+ assert.isRejected(
60
+ webex.internal.team.createConversation({url}, {}),
61
+ /`params.displayName` is required/
62
+ ));
63
+
64
+ it('requires a team object with a general conversation', () =>
65
+ assert.isRejected(
66
+ webex.internal.team.createConversation({url}, {displayName}),
67
+ /`team.generalConversationUuid` must be present/
68
+ ));
69
+ });
70
+
71
+ describe('#get()', () => {
72
+ it('requires a team url', () =>
73
+ assert.isRejected(webex.internal.team.get({}), /`team.url` is required/));
74
+ });
75
+
76
+ describe('#listConversations()', () => {
77
+ it('requires a team url', () =>
78
+ assert.isRejected(webex.internal.team.listConversations({}), /`team.url` is required/));
79
+ });
80
+
81
+ describe('#prepareTeamConversation()', () => {
82
+ it('requires a KRO', () =>
83
+ assert.isRejected(
84
+ webex.internal.team._prepareTeamConversation({}),
85
+ /Team general conversation must have a KRO/
86
+ ));
87
+ });
88
+
89
+ describe('#recordUUIDs', () => {
90
+ it('resolves if there are no teamMembers', () =>
91
+ webex.internal.team
92
+ ._recordUUIDs({})
93
+ .then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0)));
94
+
95
+ it("resolves if there isn't teamMembers.items", () =>
96
+ webex.internal.team
97
+ ._recordUUIDs({teamMembers: {}})
98
+ .then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0)));
99
+
100
+ it('resolves if there is a LYRA_SPACE user', () => {
101
+ const user = {
102
+ id: uuid.v4(),
103
+ type: 'LYRA_SPACE',
104
+ };
105
+
106
+ return webex.internal.team
107
+ ._recordUUIDs({teamMembers: {[user.id]: user}})
108
+ .then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0));
109
+ });
110
+ });
111
+
112
+ describe('#joinConversation', () => {
113
+ const conversation = {kmsResourceObjectUrl: 'convoKroUrl', id: 'convoId'};
114
+ const team = {url: 'teamUrl'};
115
+ const userId = 'userId';
116
+
117
+ beforeEach(() => {
118
+ webex.credentials.supertoken = {access_token: 'fake_token'};
119
+ });
120
+
121
+ it('requires userId to joinConversation', () =>
122
+ assert.isRejected(webex.internal.team.joinConversation(team, conversation), /`userId` is required/));
123
+
124
+ it('makes POST to convo service with correct body kmsMessage', () => {
125
+ webex.credentials.supertoken = {access_token: 'fake_token'}
126
+ return webex.internal.team.joinConversation(team, conversation, userId).then(() => {
127
+ assert.calledWith(
128
+ webex.request,
129
+ sinon.match({
130
+ method: 'POST',
131
+ uri: `${team.url}/conversations/${conversation.id}/participants`,
132
+ body: {
133
+ kmsMessage: {
134
+ client: {
135
+ clientId: webex.internal.device.url,
136
+ credential: {
137
+ bearer: webex.credentials.supertoken.access_token,
138
+ userId,
139
+ },
140
+ },
141
+ method: 'create',
142
+ resourceUri: conversation.kmsResourceObjectUrl,
143
+ uri: '/authorizations',
144
+ userIds: [userId],
145
+ }
146
+ },
147
+ })
148
+ );
149
+ })
150
+ })
151
+ })
152
+ });
153
+ });