1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' 17import cloudData from '@ohos.data.cloudData' 18import data_relationalStore from '@ohos.data.relationalStore'; 19import featureAbility from '@ohos.ability.featureAbility'; 20 21const TAG = "[CLOUD_SHARE_JSKITS_TEST]" 22const STORE_NAME = "cloud_rdb.db" 23let rdbStore = undefined; 24let context = featureAbility.getContext() 25const SHARING_RESOURCE = "test sharing resource" 26const INVITATION_CODE = "test invitation code" 27let privilegeEnable = { 28 writable: true, 29 readable: true, 30 creatable: true, 31 deletable: true, 32 shareable: true 33} 34let privilegeDisable = { 35 writable: false, 36 readable: false, 37 creatable: false, 38 deletable: false, 39 shareable: false 40} 41let participants1 = { 42 identity: '0000000000', 43 role: cloudData.sharing.Role.ROLE_INVITER, 44 state: cloudData.sharing.State.STATE_UNKNOWN, 45 privilege: privilegeEnable, 46 attachInfo: 'attachInfo1' 47} 48let participants2 = { 49 identity: '1111111111', 50 role: cloudData.sharing.Role.ROLE_INVITER, 51 state: cloudData.sharing.State.STATE_UNKNOWN, 52 privilege: privilegeDisable, 53 attachInfo: 'attachInfo2' 54} 55let participants = [participants1, participants2]; 56const rowCount = 1; 57 58describe('cloudSharingTest', function () { 59 beforeAll(async function (done) { 60 console.info("beforeAll"); 61 const config = { 62 name: STORE_NAME, 63 securityLevel: data_relationalStore.SecurityLevel.S1, 64 } 65 try { 66 rdbStore = await data_relationalStore.getRdbStore(context, config); 67 console.log(TAG + "create rdb store success") 68 let sqlStatement = "CREATE TABLE IF NOT EXISTS employee (" + 69 "id INTEGER PRIMARY KEY AUTOINCREMENT," + 70 "name TEXT NOT NULL," + 71 "age INTEGER)" 72 await rdbStore.executeSql(sqlStatement, null) 73 console.log(TAG + "create table employee success") 74 75 let valueBucket = { 76 id: 1, 77 name: "Linda", 78 age: 18 79 } 80 await rdbStore.insert("employee", valueBucket).then((rowId) => { 81 console.info(`Insert is successful, rowId = ${rowId}`); 82 }); 83 done(); 84 } catch (err) { 85 console.log(TAG + "create rdb store failed" + `, error code is ${err.code}, message is ${err.message}`) 86 expect(null).assertFail() 87 } 88 }) 89 90 beforeEach(function () { 91 console.info("beforeEach"); 92 }) 93 94 afterEach(function () { 95 console.info("afterEach"); 96 }) 97 98 afterAll(async function () { 99 console.info("afterAll"); 100 const DROP_TABLE_EMPLOYEE = "DROP TABLE IF EXISTS employee"; 101 await rdbStore.executeSql(DROP_TABLE_EMPLOYEE, null); 102 rdbStore = null 103 await data_relationalStore.deleteRdbStore(context, STORE_NAME); 104 }) 105 106 /** 107 * @tc.number SUB_DDM_CLOUD_SHARE_0010 108 * @tc.name allocResourceAndShareTest001 109 * @tc.desc Test Js Api allocResourceAndShare with invalid args. 110 */ 111 it('allocResourceAndShareTest001', 0, async function (done) { 112 console.log(TAG + "************* allocResourceAndShareTest001 start *************"); 113 try { 114 let predicates = new data_relationalStore.RdbPredicates("employee"); 115 predicates.equalTo("id", 1); 116 cloudData.sharing.allocResourceAndShare(undefined, predicates, participants, (err, resultSet) => { 117 done() 118 if (err) { 119 console.log(TAG + `allocate resource and share failed, errcode:${err.code}, message ${err.message}.`); 120 } 121 expect(null).assertFail(); 122 }) 123 } catch (err) { 124 expect(err.code == 401).assertTrue(); 125 } 126 done() 127 console.log(TAG + "************* allocResourceAndShareTest001 end *************"); 128 }) 129 130 /** 131 * @tc.number SUB_DDM_CLOUD_SHARE_0010 132 * @tc.name allocResourceAndShareTest002 133 * @tc.desc Test Js Api allocResourceAndShare with invalid args. 134 */ 135 it('allocResourceAndShareTest002', 0, async function (done) { 136 console.log(TAG + "************* allocResourceAndShareTest002 start *************"); 137 try { 138 cloudData.sharing.allocResourceAndShare("employee", undefined, participants, (err, resultSet) => { 139 done() 140 if (err) { 141 console.log(TAG + `allocate resource and share failed, errcode:${err.code}, message ${err.message}.`); 142 } 143 expect(null).assertFail(); 144 }) 145 } catch (err) { 146 expect(err.code == 401).assertTrue(); 147 } 148 done() 149 console.log(TAG + "************* allocResourceAndShareTest002 end *************"); 150 }) 151 152 /** 153 * @tc.number SUB_DDM_CLOUD_SHARE_0010 154 * @tc.name allocResourceAndShareTest003 155 * @tc.desc Test Js Api allocResourceAndShare with invalid args. 156 */ 157 it('allocResourceAndShareTest003', 0, async function (done) { 158 console.log(TAG + "************* allocResourceAndShareTest003 start *************"); 159 try { 160 cloudData.sharing 161 let predicates = new data_relationalStore.RdbPredicates("employee"); 162 predicates.equalTo("id", 1); 163 cloudData.sharing.allocResourceAndShare("employee", predicates, undefined, (err, resultSet) => { 164 done() 165 if (err) { 166 console.log(TAG + `allocate resource and share failed, errcode:${err.code}, message ${err.message}.`); 167 } 168 expect(null).assertFail(); 169 }) 170 } catch (err) { 171 expect(err.code == 401).assertTrue(); 172 } 173 done() 174 console.log(TAG + "************* allocResourceAndShareTest003 end *************"); 175 }) 176 177 /** 178 * @tc.number SUB_DDM_CLOUD_SHARE_0010 179 * @tc.name allocResourceAndShareTest004 180 * @tc.desc Test Js Api allocResourceAndShare with invalid args. 181 */ 182 it('allocResourceAndShareTest004', 0, async function (done) { 183 console.log(TAG + "************* allocResourceAndShareTest004 start *************"); 184 try { 185 let predicates = new data_relationalStore.RdbPredicates("employee"); 186 predicates.equalTo("id", 1); 187 const columns = ["id", "name", "age"]; 188 await cloudData.sharing.allocResourceAndShare(undefined, predicates, participants, columns).then((resultSet) => { 189 expect(null).assertFail(); 190 }).catch((err) => { 191 expect(null).assertFail(); 192 }) 193 } catch (err) { 194 expect(err.code == 401).assertTrue() 195 } 196 done() 197 console.log(TAG + "************* allocResourceAndShareTest004 end *************"); 198 }) 199 200 /** 201 * @tc.number SUB_DDM_CLOUD_SHARE_0010 202 * @tc.name allocResourceAndShareTest005 203 * @tc.desc Test Js Api allocResourceAndShare with invalid args. 204 */ 205 it('allocResourceAndShareTest005', 0, async function (done) { 206 console.log(TAG + "************* allocResourceAndShareTest005 start *************"); 207 try { 208 const columns = ["id", "name", "age"]; 209 await cloudData.sharing.allocResourceAndShare("employee", undefined, participants, columns).then((resultSet) => { 210 expect(null).assertFail(); 211 }).catch((err) => { 212 expect(null).assertFail(); 213 }) 214 } catch (err) { 215 expect(err.code == 401).assertTrue() 216 } 217 done() 218 console.log(TAG + "************* allocResourceAndShareTest005 end *************"); 219 }) 220 221 /** 222 * @tc.number SUB_DDM_CLOUD_SHARE_0010 223 * @tc.name allocResourceAndShareTest006 224 * @tc.desc Test Js Api allocResourceAndShare with invalid args. 225 */ 226 it('allocResourceAndShareTest006', 0, async function (done) { 227 console.log(TAG + "************* allocResourceAndShareTest006 start *************"); 228 try { 229 let predicates = new data_relationalStore.RdbPredicates("employee"); 230 predicates.equalTo("id", 1); 231 const columns = ["id", "name", "age"]; 232 cloudData.sharing.allocResourceAndShare("employee", predicates, undefined, columns).then((resultSet) => { 233 expect(null).assertFail(); 234 }).catch((err) => { 235 expect(null).assertFail(); 236 }) 237 } catch (err) { 238 expect(err.code == 401).assertTrue() 239 } 240 done(); 241 console.log(TAG + "************* allocResourceAndShareTest006 end *************"); 242 }) 243 244 /** 245 * @tc.number SUB_DDM_CLOUD_SHARE_0010 246 * @tc.name shareTest001 247 * @tc.desc Test Js Api share with invalid args. 248 */ 249 it("shareTest001", 0, async function (done) { 250 console.log(TAG + "************* shareTest001 start *************"); 251 try { 252 cloudData.sharing.share(undefined, participants, ((err, result) => { 253 if (err) { 254 expect(null).assertFail(); 255 } 256 expect(null).assertFail(); 257 })) 258 } catch (err) { 259 expect(err.code == 401).assertTrue(); 260 } 261 done(); 262 console.log(TAG + "************* shareTest001 end *************"); 263 }) 264 265 /** 266 * @tc.number SUB_DDM_CLOUD_SHARE_0010 267 * @tc.name shareTest002 268 * @tc.desc Test Js Api share with invalid args. 269 */ 270 it("shareTest002", 0, async function (done) { 271 console.log(TAG + "************* shareTest002 start *************"); 272 try { 273 cloudData.sharing.share(SHARING_RESOURCE, undefined, ((err, result) => { 274 if (err) { 275 expect(null).assertFail(); 276 } 277 expect(null).assertFail(); 278 })) 279 } catch (err) { 280 expect(err.code == 401).assertTrue(); 281 } 282 done(); 283 console.log(TAG + "************* shareTest002 end *************"); 284 }) 285 286 /** 287 * @tc.number SUB_DDM_CLOUD_SHARE_0010 288 * @tc.name shareTest003 289 * @tc.desc Test Js Api share with invalid args. 290 */ 291 it("shareTest003", 0, async function (done) { 292 console.log(TAG + "************* shareTest003 start *************"); 293 try { 294 cloudData.sharing.share(undefined, participants).then(result => { 295 expect(null).assertFail(); 296 }).catch(err => { 297 expect(null).assertFail(); 298 }) 299 } catch (err) { 300 expect(err.code == 401).assertTrue(); 301 } 302 done() 303 console.log(TAG + "************* shareTest003 end *************"); 304 }) 305 306 /** 307 * @tc.number SUB_DDM_CLOUD_SHARE_0010 308 * @tc.name shareTest004 309 * @tc.desc Test Js Api share with invalid args. 310 */ 311 it("shareTest004", 0, async function (done) { 312 console.log(TAG + "************* shareTest004 start *************"); 313 try { 314 cloudData.sharing.share(SHARING_RESOURCE, undefined).then(result => { 315 expect(null).assertFail(); 316 }).catch(err => { 317 expect(null).assertFail(); 318 }) 319 } catch (err) { 320 expect(err.code == 401).assertTrue(); 321 } 322 done() 323 console.log(TAG + "************* shareTest004 end *************"); 324 }) 325 326 /** 327 * @tc.number SUB_DDM_CLOUD_SHARE_0010 328 * @tc.name unshareTest001 329 * @tc.desc Test Js Api unshare with invalid args. 330 */ 331 it("unshareTest001", 0, async function (done) { 332 console.log(TAG + "************* unshareTest001 start *************"); 333 try { 334 cloudData.sharing.unshare(undefined, participants, ((err, result) => { 335 if (err) { 336 expect(null).assertFail(); 337 } 338 expect(null).assertFail(); 339 })) 340 } catch (err) { 341 expect(err.code == 401).assertTrue(); 342 } 343 done(); 344 console.log(TAG + "************* unshareTest001 end *************"); 345 }) 346 347 /** 348 * @tc.number SUB_DDM_CLOUD_SHARE_0010 349 * @tc.name unshareTest002 350 * @tc.desc Test Js Api unshare with invalid args. 351 */ 352 it("unshareTest002", 0, async function (done) { 353 console.log(TAG + "************* unshareTest002 start *************"); 354 try { 355 cloudData.sharing.unshare(SHARING_RESOURCE, undefined, ((err, result) => { 356 if (err) { 357 expect(null).assertFail(); 358 } 359 expect(null).assertFail(); 360 })) 361 } catch (err) { 362 expect(err.code == 401).assertTrue(); 363 } 364 done(); 365 console.log(TAG + "************* unshareTest002 end *************"); 366 }) 367 368 /** 369 * @tc.number SUB_DDM_CLOUD_SHARE_0010 370 * @tc.name unshareTest003 371 * @tc.desc Test Js Api unshare with invalid args. 372 */ 373 it("unshareTest003", 0, async function (done) { 374 console.log(TAG + "************* unshareTest003 start *************"); 375 try { 376 cloudData.sharing.unshare(undefined, participants).then(result => { 377 expect(null).assertFail(); 378 }).catch(err => { 379 expect(null).assertFail(); 380 }) 381 } catch (err) { 382 expect(err.code == 401).assertTrue(); 383 } 384 done() 385 console.log(TAG + "************* unshareTest003 end *************"); 386 }) 387 388 /** 389 * @tc.number SUB_DDM_CLOUD_SHARE_0010 390 * @tc.name unshareTest004 391 * @tc.desc Test Js Api unshare with invalid args. 392 */ 393 it("unshareTest004", 0, async function (done) { 394 console.log(TAG + "************* unshareTest004 start *************"); 395 try { 396 cloudData.sharing.unshare(SHARING_RESOURCE, undefined).then(result => { 397 expect(null).assertFail(); 398 }).catch(err => { 399 expect(null).assertFail(); 400 }) 401 } catch (err) { 402 expect(err.code == 401).assertTrue(); 403 } 404 done() 405 console.log(TAG + "************* unshareTest004 end *************"); 406 }) 407 408 /** 409 * @tc.number SUB_DDM_CLOUD_SHARE_0010 410 * @tc.name exitTest001 411 * @tc.desc Test Js Api exit with invalid args. 412 */ 413 it("exitTest001", 0, async function (done) { 414 console.log(TAG + "************* exitTest001 start *************"); 415 try { 416 cloudData.sharing.exit(undefined, ((err, result) => { 417 if (err) { 418 expect(null).assertFail(); 419 } 420 expect(null).assertFail(); 421 })) 422 } catch (err) { 423 expect(err.code == 401).assertTrue(); 424 } 425 done(); 426 console.log(TAG + "************* exitTest001 end *************"); 427 }) 428 429 /** 430 * @tc.number SUB_DDM_CLOUD_SHARE_0010 431 * @tc.name exitTest002 432 * @tc.desc Test Js Api exit with invalid args. 433 */ 434 it("exitTest002", 0, async function (done) { 435 console.log(TAG + "************* exitTest002 start *************"); 436 try { 437 cloudData.sharing.exit(undefined).then(result => { 438 expect(null).assertFail(); 439 }).catch(err => { 440 expect(null).assertFail(); 441 }) 442 } catch (err) { 443 expect(err.code == 401).assertTrue(); 444 } 445 done() 446 console.log(TAG + "************* exitTest002 end *************"); 447 }) 448 449 /** 450 * @tc.number SUB_DDM_CLOUD_SHARE_0010 451 * @tc.name changePrivilegeTest001 452 * @tc.desc Test Js Api changePrivilege with invalid args. 453 */ 454 it("changePrivilegeTest001", 0, async function (done) { 455 console.log(TAG + "************* changePrivilegeTest001 start *************"); 456 try { 457 let changed1 = participants1; 458 changed1.privilege = privilegeDisable; 459 let changed2 = participants2; 460 changed2.privilege = privilegeEnable; 461 const changePart = [changed1, changed2]; 462 cloudData.sharing.changePrivilege(undefined, changePart, ((err, result) => { 463 if (err) { 464 expect(null).assertFail(); 465 } 466 expect(null).assertFail(); 467 })) 468 } catch (err) { 469 expect(err.code == 401).assertTrue(); 470 } 471 done() 472 console.log(TAG + "************* changePrivilegeTest001 end *************"); 473 }) 474 475 /** 476 * @tc.number SUB_DDM_CLOUD_SHARE_0010 477 * @tc.name changePrivilegeTest002 478 * @tc.desc Test Js Api changePrivilege with invalid args. 479 */ 480 it("changePrivilegeTest002", 0, async function (done) { 481 console.log(TAG + "************* changePrivilegeTest002 start *************"); 482 try { 483 cloudData.sharing.changePrivilege(SHARING_RESOURCE, undefined, ((err, result) => { 484 if (err) { 485 expect(null).assertFail(); 486 } 487 expect(null).assertFail(); 488 })) 489 } catch (err) { 490 expect(err.code == 401).assertTrue(); 491 } 492 done() 493 console.log(TAG + "************* changePrivilegeTest002 end *************"); 494 }) 495 496 /** 497 * @tc.number SUB_DDM_CLOUD_SHARE_0010 498 * @tc.name changePrivilegeTest003 499 * @tc.desc Test Js Api changePrivilege with invalid args. 500 */ 501 it("changePrivilegeTest003", 0, async function (done) { 502 console.log(TAG + "************* changePrivilegeTest003 start *************"); 503 try { 504 let changed1 = participants1; 505 changed1.privilege = privilegeDisable; 506 let changed2 = participants2; 507 changed2.privilege = privilegeEnable; 508 const changePart = [changed1, changed2]; 509 cloudData.sharing.changePrivilege(undefined, changePart).then(result => { 510 expect(null).assertFail(); 511 }).catch(err => { 512 expect(null).assertFail(); 513 }) 514 } catch (err) { 515 expect(err.code == 401).assertTrue(); 516 } 517 done() 518 console.log(TAG + "************* changePrivilegeTest003 end *************"); 519 }) 520 521 /** 522 * @tc.number SUB_DDM_CLOUD_SHARE_0010 523 * @tc.name changePrivilegeTest004 524 * @tc.desc Test Js Api changePrivilege with invalid args. 525 */ 526 it("changePrivilegeTest004", 0, async function (done) { 527 console.log(TAG + "************* changePrivilegeTest004 start *************"); 528 try { 529 cloudData.sharing.changePrivilege(SHARING_RESOURCE, undefined).then(result => { 530 expect(null).assertFail(); 531 }).catch(err => { 532 expect(null).assertFail(); 533 }) 534 } catch (err) { 535 expect(err.code == 401).assertTrue(); 536 } 537 done() 538 console.log(TAG + "************* changePrivilegeTest004 end *************"); 539 }) 540 541 /** 542 * @tc.number SUB_DDM_CLOUD_SHARE_0010 543 * @tc.name queryParticipantsTest001 544 * @tc.desc Test Js Api queryParticipants with invalid args. 545 */ 546 it("queryParticipantsTest001", 0, async function (done) { 547 console.log(TAG + "************* queryParticipantsTest001 start *************"); 548 try { 549 cloudData.sharing.queryParticipants(undefined, ((err, result) => { 550 if (err) { 551 expect(null).assertFail(); 552 } 553 expect(null).assertFail(); 554 })) 555 } catch (err) { 556 expect(err.code == 401).assertTrue(); 557 } 558 done(); 559 console.log(TAG + "************* queryParticipantsTest001 end *************"); 560 }) 561 562 /** 563 * @tc.number SUB_DDM_CLOUD_SHARE_0010 564 * @tc.name queryParticipantsTest002 565 * @tc.desc Test Js Api queryParticipants with invalid args. 566 */ 567 it("queryParticipantsTest002", 0, async function (done) { 568 console.log(TAG + "************* queryParticipantsTest002 start *************"); 569 try { 570 cloudData.sharing.queryParticipants(undefined).then(result => { 571 expect(null).assertFail(); 572 573 574 }).catch(err => { 575 expect(null).assertFail(); 576 }) 577 } catch (err) { 578 expect(err.code == 401).assertTrue(); 579 } 580 done() 581 console.log(TAG + "************* queryParticipantsTest002 end *************"); 582 }) 583 584 /** 585 * @tc.number SUB_DDM_CLOUD_SHARE_0010 586 * @tc.name queryParticipantsByInvitationTest003 587 * @tc.desc Test Js Api queryParticipantsByInvitation with invalid args. 588 */ 589 it("queryParticipantsByInvitationTest003", 0, async function (done) { 590 console.log(TAG + "************* queryParticipantsByInvitationTest003 start *************"); 591 try { 592 cloudData.sharing.queryParticipantsByInvitation(undefined, ((err, result) => { 593 if (err) { 594 expect(null).assertFail(); 595 } 596 expect(null).assertFail(); 597 })) 598 } catch (err) { 599 expect(err.code == 401).assertTrue(); 600 } 601 done(); 602 console.log(TAG + "************* queryParticipantsByInvitationTest003 end *************"); 603 }) 604 605 /** 606 * @tc.number SUB_DDM_CLOUD_SHARE_0010 607 * @tc.name queryParticipantsByInvitationTest004 608 * @tc.desc Test Js Api queryParticipantsByInvitation with invalid args. 609 */ 610 it("queryParticipantsByInvitationTest004", 0, async function (done) { 611 console.log(TAG + "************* queryParticipantsByInvitationTest004 start *************"); 612 try { 613 cloudData.sharing.queryParticipantsByInvitation(undefined).then(result => { 614 expect(null).assertFail(); 615 }).catch(err => { 616 expect(null).assertFail(); 617 }) 618 } catch (err) { 619 expect(err.code == 401).assertTrue(); 620 } 621 done() 622 console.log(TAG + "************* queryParticipantsByInvitationTest004 end *************"); 623 }) 624 625 /** 626 * @tc.number SUB_DDM_CLOUD_SHARE_0010 627 * @tc.name confirmInvitationTest001 628 * @tc.desc Test Js Api confirmInvitation with invalid args. 629 */ 630 it("confirmInvitationTest001", 0, async function (done) { 631 console.log(TAG + "************* confirmInvitationTest001 start *************"); 632 try { 633 cloudData.sharing.confirmInvitation(undefined, cloudData.sharing.State.STATE_SUSPENDED, ((err, result) => { 634 if (err) { 635 expect(null).assertFail(); 636 } 637 expect(null).assertFail(); 638 })) 639 } catch (err) { 640 expect(err.code == 401).assertTrue(); 641 } 642 done() 643 console.log(TAG + "************* confirmInvitationTest001 end *************"); 644 }) 645 646 /** 647 * @tc.number SUB_DDM_CLOUD_SHARE_0010 648 * @tc.name confirmInvitationTest002 649 * @tc.desc Test Js Api confirmInvitation with invalid args. 650 */ 651 it("confirmInvitationTest002", 0, async function (done) { 652 console.log(TAG + "************* confirmInvitationTest002 start *************"); 653 try { 654 cloudData.sharing.confirmInvitation(INVITATION_CODE, 100, ((err, result) => { 655 if (err) { 656 expect(null).assertFail(); 657 } 658 expect(null).assertFail(); 659 })) 660 } catch (err) { 661 expect(err.code == 401).assertTrue(); 662 } 663 done() 664 console.log(TAG + "************* confirmInvitationTest002 end *************"); 665 }) 666 667 /** 668 * @tc.number SUB_DDM_CLOUD_SHARE_0010 669 * @tc.name confirmInvitationTest003 670 * @tc.desc Test Js Api confirmInvitation with invalid args. 671 */ 672 it("confirmInvitationTest003", 0, async function (done) { 673 console.log(TAG + "************* confirmInvitationTest003 start *************"); 674 try { 675 cloudData.sharing.confirmInvitation(INVITATION_CODE, undefined, ((err, result) => { 676 if (err) { 677 expect(null).assertFail(); 678 } 679 expect(null).assertFail(); 680 })) 681 } catch (err) { 682 expect(err.code == 401).assertTrue(); 683 } 684 done() 685 console.log(TAG + "************* confirmInvitationTest003 end *************"); 686 }) 687 688 /** 689 * @tc.number SUB_DDM_CLOUD_SHARE_0010 690 * @tc.name confirmInvitationTest004 691 * @tc.desc Test Js Api confirmInvitation with invalid args. 692 */ 693 it("confirmInvitationTest004", 0, async function (done) { 694 console.log(TAG + "************* confirmInvitationTest004 start *************"); 695 try { 696 cloudData.sharing.confirmInvitation(undefined, cloudData.sharing.State.STATE_SUSPENDED).then(result => { 697 expect(null).assertFail(); 698 }).catch(err => { 699 expect(null).assertFail(); 700 }) 701 } catch (err) { 702 expect(err.code == 401).assertTrue(); 703 } 704 done() 705 console.log(TAG + "************* confirmInvitationTest004 end *************"); 706 }) 707 708 /** 709 * @tc.number SUB_DDM_CLOUD_SHARE_0010 710 * @tc.name confirmInvitationTest005 711 * @tc.desc Test Js Api confirmInvitation with invalid args. 712 */ 713 it("confirmInvitationTest005", 0, async function (done) { 714 console.log(TAG + "************* confirmInvitationTest005 start *************"); 715 try { 716 cloudData.sharing.confirmInvitation(SHARING_RESOURCE, 100).then(result => { 717 expect(null).assertFail(); 718 }).catch(err => { 719 expect(null).assertFail(); 720 }) 721 } catch (err) { 722 expect(err.code == 401).assertTrue(); 723 } 724 done() 725 console.log(TAG + "************* confirmInvitationTest005 end *************"); 726 }) 727 728 /** 729 * @tc.number SUB_DDM_CLOUD_SHARE_0010 730 * @tc.name confirmInvitationTest006 731 * @tc.desc Test Js Api confirmInvitation with invalid args. 732 */ 733 it("confirmInvitationTest006", 0, async function (done) { 734 console.log(TAG + "************* confirmInvitationTest006 start *************"); 735 try { 736 cloudData.sharing.confirmInvitation(SHARING_RESOURCE, undefined).then(result => { 737 expect(null).assertFail(); 738 }).catch(err => { 739 expect(null).assertFail(); 740 }) 741 } catch (err) { 742 expect(err.code == 401).assertTrue(); 743 } 744 done() 745 console.log(TAG + "************* confirmInvitationTest006 end *************"); 746 }) 747 748 /** 749 * @tc.number SUB_DDM_CLOUD_SHARE_0010 750 * @tc.name changeConfirmationTest001 751 * @tc.desc Test Js Api changeConfirmation with invalid args. 752 */ 753 it("changeConfirmationTest001", 0, async function (done) { 754 console.log(TAG + "************* changeConfirmationTest001 start *************"); 755 try { 756 cloudData.sharing.changeConfirmation(undefined, cloudData.sharing.State.STATE_SUSPENDED, ((err, result) => { 757 if (err) { 758 expect(null).assertFail(); 759 } 760 expect(null).assertFail(); 761 })) 762 } catch (err) { 763 expect(err.code == 401).assertTrue(); 764 } 765 done() 766 console.log(TAG + "************* changeConfirmationTest001 end *************"); 767 }) 768 769 /** 770 * @tc.number SUB_DDM_CLOUD_SHARE_0010 771 * @tc.name changeConfirmationTest002 772 * @tc.desc Test Js Api changeConfirmation with invalid args. 773 */ 774 it("changeConfirmationTest002", 0, async function (done) { 775 console.log(TAG + "************* changeConfirmationTest002 start *************"); 776 try { 777 cloudData.sharing.changeConfirmation(SHARING_RESOURCE, 100, ((err, result) => { 778 if (err) { 779 expect(null).assertFail(); 780 } 781 expect(null).assertFail(); 782 })) 783 } catch (err) { 784 expect(err.code == 401).assertTrue(); 785 } 786 done() 787 console.log(TAG + "************* changeConfirmationTest002 end *************"); 788 }) 789 790 /** 791 * @tc.number SUB_DDM_CLOUD_SHARE_0010 792 * @tc.name changeConfirmationTest003 793 * @tc.desc Test Js Api changeConfirmation with invalid args. 794 */ 795 it("changeConfirmationTest003", 0, async function (done) { 796 console.log(TAG + "************* changeConfirmationTest003 start *************"); 797 try { 798 cloudData.sharing.changeConfirmation(SHARING_RESOURCE, undefined, ((err, result) => { 799 if (err) { 800 expect(null).assertFail(); 801 } 802 expect(null).assertFail(); 803 })) 804 } catch (err) { 805 expect(err.code == 401).assertTrue(); 806 } 807 done() 808 console.log(TAG + "************* changeConfirmationTest003 end *************"); 809 }) 810 811 /** 812 * @tc.number SUB_DDM_CLOUD_SHARE_0010 813 * @tc.name changeConfirmationTest004 814 * @tc.desc Test Js Api changeConfirmation with invalid args. 815 */ 816 it("changeConfirmationTest004", 0, async function (done) { 817 console.log(TAG + "************* changeConfirmationTest004 start *************"); 818 try { 819 cloudData.sharing.changeConfirmation(undefined, cloudData.sharing.State.STATE_SUSPENDED).then(result => { 820 expect(null).assertFail(); 821 }).catch(err => { 822 expect(null).assertFail(); 823 }) 824 } catch (err) { 825 expect(err.code == 401).assertTrue(); 826 } 827 done() 828 console.log(TAG + "************* changeConfirmationTest004 end *************"); 829 }) 830 831 /** 832 * @tc.number SUB_DDM_CLOUD_SHARE_0010 833 * @tc.name changeConfirmationTest005 834 * @tc.desc Test Js Api changeConfirmation with invalid args. 835 */ 836 it("changeConfirmationTest005", 0, async function (done) { 837 console.log(TAG + "************* changeConfirmationTest005 start *************"); 838 try { 839 cloudData.sharing.changeConfirmation(SHARING_RESOURCE, 100).then(result => { 840 expect(null).assertFail(); 841 }).catch(err => { 842 expect(null).assertFail(); 843 }) 844 } catch (err) { 845 expect(err.code == 401).assertTrue(); 846 } 847 done() 848 console.log(TAG + "************* changeConfirmationTest005 end *************"); 849 }) 850 851 /** 852 * @tc.number SUB_DDM_CLOUD_SHARE_0010 853 * @tc.name changeConfirmationTest006 854 * @tc.desc Test Js Api changeConfirmation with invalid args. 855 */ 856 it("changeConfirmationTest006", 0, async function (done) { 857 console.log(TAG + "************* changeConfirmationTest006 start *************"); 858 try { 859 cloudData.sharing.changeConfirmation(SHARING_RESOURCE, undefined).then(result => { 860 expect(null).assertFail(); 861 }).catch(err => { 862 expect(null).assertFail(); 863 }) 864 } catch (err) { 865 expect(err.code == 401).assertTrue(); 866 } 867 done() 868 console.log(TAG + "************* changeConfirmationTest006 end *************"); 869 }) 870})