@@ -117,12 +117,12 @@ describe(commands.LIST_RETENTIONLABEL_ENSURE, () => {
117
117
debug : true ,
118
118
webUrl : 'https://contoso.sharepoint.com/sites/team1' ,
119
119
listTitle : 'MyLibrary' ,
120
- label : 'abc'
120
+ name : 'abc'
121
121
}
122
122
} as any ) , new CommandError ( '404 - "404 FILE NOT FOUND"' ) ) ;
123
123
} ) ;
124
124
125
- it ( 'should set label for list (debug) ' , async ( ) => {
125
+ it ( 'should set label for list with deprecated label ' , async ( ) => {
126
126
const postStub = sinon . stub ( request , 'post' ) . callsFake ( ( opts ) => {
127
127
if ( ( opts . url as string ) . indexOf ( `https://contoso.sharepoint.com/sites/team1/_api/SP_CompliancePolicy_SPPolicyStoreProxy_SetListComplianceTag` ) > - 1 ) {
128
128
return Promise . resolve ( ) ;
@@ -156,6 +156,40 @@ describe(commands.LIST_RETENTIONLABEL_ENSURE, () => {
156
156
assert . strictEqual ( lastCall . data . syncToItems , false ) ;
157
157
} ) ;
158
158
159
+ it ( 'should set label for list (debug)' , async ( ) => {
160
+ const postStub = sinon . stub ( request , 'post' ) . callsFake ( ( opts ) => {
161
+ if ( ( opts . url as string ) . indexOf ( `https://contoso.sharepoint.com/sites/team1/_api/SP_CompliancePolicy_SPPolicyStoreProxy_SetListComplianceTag` ) > - 1 ) {
162
+ return Promise . resolve ( ) ;
163
+ }
164
+
165
+ return Promise . reject ( 'Invalid request' ) ;
166
+ } ) ;
167
+
168
+ sinon . stub ( request , 'get' ) . callsFake ( ( opts ) => {
169
+ if ( opts . url === `https://contoso.sharepoint.com/sites/team1/_api/web/lists/getByTitle('MyLibrary')/?$expand=RootFolder&$select=RootFolder` ) {
170
+ return Promise . resolve ( { "RootFolder" : { "Exists" : true , "IsWOPIEnabled" : false , "ItemCount" : 0 , "Name" : "MyLibrary" , "ProgID" : null , "ServerRelativeUrl" : "/sites/team1/MyLibrary" , "TimeCreated" : "2019-01-11T10:03:19Z" , "TimeLastModified" : "2019-01-11T10:03:20Z" , "UniqueId" : "faaa6af2-0157-4e9a-a352-6165195923c8" , "WelcomePage" : "" } }
171
+ ) ;
172
+ }
173
+
174
+ return Promise . reject ( 'Invalid request' ) ;
175
+ } ) ;
176
+
177
+ await command . action ( logger , {
178
+ options : {
179
+ debug : true ,
180
+ webUrl : 'https://contoso.sharepoint.com/sites/team1' ,
181
+ listTitle : 'MyLibrary' ,
182
+ name : 'abc'
183
+ }
184
+ } ) ;
185
+ const lastCall = postStub . lastCall . args [ 0 ] ;
186
+ assert . strictEqual ( lastCall . data . listUrl , 'https://contoso.sharepoint.com/sites/team1/MyLibrary' ) ;
187
+ assert . strictEqual ( lastCall . data . complianceTagValue , 'abc' ) ;
188
+ assert . strictEqual ( lastCall . data . blockDelete , false ) ;
189
+ assert . strictEqual ( lastCall . data . blockEdit , false ) ;
190
+ assert . strictEqual ( lastCall . data . syncToItems , false ) ;
191
+ } ) ;
192
+
159
193
it ( 'should set label for list using listId (debug)' , async ( ) => {
160
194
const postStub = sinon . stub ( request , 'post' ) . callsFake ( ( opts ) => {
161
195
if ( ( opts . url as string ) . indexOf ( `https://contoso.sharepoint.com/sites/team1/_api/SP_CompliancePolicy_SPPolicyStoreProxy_SetListComplianceTag` ) > - 1 ) {
@@ -178,7 +212,7 @@ describe(commands.LIST_RETENTIONLABEL_ENSURE, () => {
178
212
options : {
179
213
webUrl : 'https://contoso.sharepoint.com/sites/team1' ,
180
214
listId : '4d535433-2a7b-40b0-9dad-8f0f8f3b3841' ,
181
- label : 'abc'
215
+ name : 'abc'
182
216
}
183
217
} ) ;
184
218
const lastCall = postStub . lastCall . args [ 0 ] ;
@@ -202,7 +236,7 @@ describe(commands.LIST_RETENTIONLABEL_ENSURE, () => {
202
236
options : {
203
237
webUrl : 'https://contoso.sharepoint.com/sites/team1' ,
204
238
listUrl : 'MyLibrary' ,
205
- label : 'abc' ,
239
+ name : 'abc' ,
206
240
blockDelete : true ,
207
241
blockEdit : true ,
208
242
syncToItems : true
@@ -222,33 +256,22 @@ describe(commands.LIST_RETENTIONLABEL_ENSURE, () => {
222
256
} ) ;
223
257
224
258
it ( 'passes validation if the url option is a valid SharePoint site URL' , async ( ) => {
225
- const actual = await command . validate ( { options : { webUrl : 'https://contoso.sharepoint.com' , label : 'abc' , listId : '0CD891EF-AFCE-4E55-B836-FCE03286CCCF' } } , commandInfo ) ;
259
+ const actual = await command . validate ( { options : { webUrl : 'https://contoso.sharepoint.com' , name : 'abc' , listId : '0CD891EF-AFCE-4E55-B836-FCE03286CCCF' } } , commandInfo ) ;
226
260
assert ( actual ) ;
227
261
} ) ;
228
262
229
263
it ( 'fails validation if the listid option is not a valid GUID' , async ( ) => {
230
- const actual = await command . validate ( { options : { webUrl : 'https://contoso.sharepoint.com' , label : 'abc' , listId : 'XXXXX' } } , commandInfo ) ;
264
+ const actual = await command . validate ( { options : { webUrl : 'https://contoso.sharepoint.com' , name : 'abc' , listId : 'XXXXX' } } , commandInfo ) ;
231
265
assert . notStrictEqual ( actual , true ) ;
232
266
} ) ;
233
267
234
268
it ( 'passes validation if the listid option is a valid GUID' , async ( ) => {
235
- const actual = await command . validate ( { options : { webUrl : 'https://contoso.sharepoint.com' , label : 'abc' , listId : 'cc27a922-8224-4296-90a5-ebbc54da2e85' } } , commandInfo ) ;
269
+ const actual = await command . validate ( { options : { webUrl : 'https://contoso.sharepoint.com' , name : 'abc' , listId : 'cc27a922-8224-4296-90a5-ebbc54da2e85' } } , commandInfo ) ;
236
270
assert ( actual ) ;
237
271
} ) ;
238
272
239
273
it ( 'fails validation if listId, listUrl and listTitle options are not passed' , async ( ) => {
240
- const actual = await command . validate ( { options : { webUrl : 'https://contoso.sharepoint.com' , label : 'abc' } } , commandInfo ) ;
274
+ const actual = await command . validate ( { options : { webUrl : 'https://contoso.sharepoint.com' , name : 'abc' } } , commandInfo ) ;
241
275
assert . notStrictEqual ( actual , true ) ;
242
276
} ) ;
243
-
244
- it ( 'supports debug mode' , ( ) => {
245
- const options = command . options ;
246
- let containsDebugOption = false ;
247
- options . forEach ( o => {
248
- if ( o . option === '--debug' ) {
249
- containsDebugOption = true ;
250
- }
251
- } ) ;
252
- assert ( containsDebugOption ) ;
253
- } ) ;
254
277
} ) ;
0 commit comments