|
538 | 538 | });
|
539 | 539 | });
|
540 | 540 |
|
| 541 | + queuedAsyncTest("Getting index values with key", function(){ |
| 542 | + var key = sample.integer(); |
| 543 | + var value = sample.obj(); |
| 544 | + _("Trying to add" + key + " and " + JSON.stringify(value)); |
| 545 | + $.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_1).add(value, key).then(function(res, e){ |
| 546 | + ok(true, "Added " + res + " to the database"); |
| 547 | + _("Added" + res + "to the database "); |
| 548 | + start(); |
| 549 | + stop(); |
| 550 | + $.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_1).index("Int").get(value.Int).then(function(res, e){ |
| 551 | + deepEqual(res, value); |
| 552 | + _("Got return value as" + res); |
| 553 | + start(); |
| 554 | + nextTest(); |
| 555 | + }, function(err, e){ |
| 556 | + ok(false, "Index Iteration NOT completed"); |
| 557 | + _("Index Iteration NOT completed"); |
| 558 | + start(); |
| 559 | + nextTest(); |
| 560 | + }); |
| 561 | + }, function(){ |
| 562 | + ok(false, "Could not add value to the database"); |
| 563 | + _("Could not add to database"); |
| 564 | + start(); |
| 565 | + nextTest(); |
| 566 | + }); |
| 567 | + }); |
| 568 | + |
| 569 | + queuedAsyncTest("Getting index-key values with key", function(){ |
| 570 | + var key = sample.integer(); |
| 571 | + var value = sample.obj(); |
| 572 | + _("Trying to add" + key + " and " + JSON.stringify(value)); |
| 573 | + $.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_1).add(value, key).then(function(res, e){ |
| 574 | + ok(true, "Added " + res + " to the database"); |
| 575 | + _("Added" + res + "to the database "); |
| 576 | + start(); |
| 577 | + stop(); |
| 578 | + $.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_1).index("Int").getKey(value.Int).then(function(res, e){ |
| 579 | + _("Got return value as" + res); |
| 580 | + equal(key, res); |
| 581 | + start(); |
| 582 | + nextTest(); |
| 583 | + }, function(err, e){ |
| 584 | + ok(false, "Index Iteration NOT completed"); |
| 585 | + _("Index Iteration NOT completed"); |
| 586 | + start(); |
| 587 | + nextTest(); |
| 588 | + }); |
| 589 | + }, function(){ |
| 590 | + ok(false, "Could not add value to the database"); |
| 591 | + _("Could not add to database"); |
| 592 | + start(); |
| 593 | + nextTest(); |
| 594 | + }); |
| 595 | + }); |
| 596 | + |
541 | 597 | queuedAsyncTest("Index iteration with keyCursor", function(){
|
542 | 598 | var key = sample.integer();
|
543 | 599 | var value = sample.obj();
|
|
0 commit comments