@webex/internal-plugin-team 3.0.0-beta.2 → 3.0.0-beta.20

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.
@@ -21,39 +21,48 @@ describe('plugin-team', () => {
21
21
  webex = new MockWebex({
22
22
  children: {
23
23
  team: Team,
24
- user: User
25
- }
24
+ user: User,
25
+ },
26
26
  });
27
27
 
28
28
  webex.internal.user.recordUUID = sinon.spy();
29
29
  });
30
30
 
31
31
  describe('#create()', () => {
32
- it('requires a displayName', () => assert.isRejected(webex.internal.team.create({}), /`params.displayName` is required/));
32
+ it('requires a displayName', () =>
33
+ assert.isRejected(webex.internal.team.create({}), /`params.displayName` is required/));
33
34
 
34
- it('requires a participants attribute', () => assert.isRejected(webex.internal.team.create({displayName: 'test'}), /`params.participants` is required/));
35
+ it('requires a participants attribute', () =>
36
+ assert.isRejected(
37
+ webex.internal.team.create({displayName: 'test'}),
38
+ /`params.participants` is required/
39
+ ));
35
40
 
36
- it('requires a participants array', () => assert.isRejected(webex.internal.team.create({displayName: 'test', participants: []}), /`params.participants` is required/));
41
+ it('requires a participants array', () =>
42
+ assert.isRejected(
43
+ webex.internal.team.create({displayName: 'test', participants: []}),
44
+ /`params.participants` is required/
45
+ ));
37
46
  });
38
47
 
39
48
  describe('#createConversation()', () => {
40
49
  const url = TEAM_URL;
41
50
  const displayName = TEAM_DISPLAY_NAME;
42
51
 
43
- it('requires a URL',
44
- () => assert.isRejected(
52
+ it('requires a URL', () =>
53
+ assert.isRejected(
45
54
  webex.internal.team.createConversation({}, {}),
46
55
  /`team.url` is required/
47
56
  ));
48
57
 
49
- it('requires a displayName',
50
- () => assert.isRejected(
58
+ it('requires a displayName', () =>
59
+ assert.isRejected(
51
60
  webex.internal.team.createConversation({url}, {}),
52
61
  /`params.displayName` is required/
53
62
  ));
54
63
 
55
- it('requires a team object with a general conversation',
56
- () => assert.isRejected(
64
+ it('requires a team object with a general conversation', () =>
65
+ assert.isRejected(
57
66
  webex.internal.team.createConversation({url}, {displayName}),
58
67
  /`team.generalConversationUuid` must be present/
59
68
  ));
@@ -61,40 +70,84 @@ describe('plugin-team', () => {
61
70
 
62
71
  describe('#get()', () => {
63
72
  it('requires a team url', () =>
64
- assert.isRejected(
65
- webex.internal.team.get({}),
66
- /`team.url` is required/
67
- ));
73
+ assert.isRejected(webex.internal.team.get({}), /`team.url` is required/));
68
74
  });
69
75
 
70
76
  describe('#listConversations()', () => {
71
77
  it('requires a team url', () =>
72
- assert.isRejected(
73
- webex.internal.team.listConversations({}),
74
- /`team.url` is required/
75
- ));
78
+ assert.isRejected(webex.internal.team.listConversations({}), /`team.url` is required/));
76
79
  });
77
80
 
78
81
  describe('#prepareTeamConversation()', () => {
79
- it('requires a KRO', () => assert.isRejected(webex.internal.team._prepareTeamConversation({}), /Team general conversation must have a KRO/));
82
+ it('requires a KRO', () =>
83
+ assert.isRejected(
84
+ webex.internal.team._prepareTeamConversation({}),
85
+ /Team general conversation must have a KRO/
86
+ ));
80
87
  });
81
88
 
82
89
  describe('#recordUUIDs', () => {
83
- it('resolves if there are no teamMembers', () => webex.internal.team._recordUUIDs({})
84
- .then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0)));
90
+ it('resolves if there are no teamMembers', () =>
91
+ webex.internal.team
92
+ ._recordUUIDs({})
93
+ .then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0)));
85
94
 
86
- it('resolves if there isn\'t teamMembers.items', () => webex.internal.team._recordUUIDs({teamMembers: {}})
87
- .then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0)));
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)));
88
99
 
89
100
  it('resolves if there is a LYRA_SPACE user', () => {
90
101
  const user = {
91
102
  id: uuid.v4(),
92
- type: 'LYRA_SPACE'
103
+ type: 'LYRA_SPACE',
93
104
  };
94
105
 
95
- return webex.internal.team._recordUUIDs({teamMembers: {[user.id]: user}})
106
+ return webex.internal.team
107
+ ._recordUUIDs({teamMembers: {[user.id]: user}})
96
108
  .then(() => assert.equal(webex.internal.user.recordUUID.callCount, 0));
97
109
  });
98
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
+ })
99
152
  });
100
153
  });