@@ -612,6 +612,56 @@ describe('Stub', () => {
612
612
} ) ;
613
613
} ) ;
614
614
615
+ describe . only ( 'getMultipleStates' , ( ) => {
616
+ it ( 'should return handler.handleGetMultipleStates results' , async ( ) => {
617
+ const handleGetMultipleStatesStub = sinon . stub ( ) . resolves ( [ 'value1' , 'value2' , 'value3' ] ) ;
618
+
619
+ const stub = new Stub ( {
620
+ handleGetMultipleStates : handleGetMultipleStatesStub
621
+ } , 'dummyChannelId' , 'dummyTxid' , chaincodeInput ) ;
622
+
623
+ const result = await stub . getMultipleStates ( 'key1' , 'key2' , 'key3' ) ;
624
+ expect ( result ) . to . deep . equal ( [ 'value1' , 'value2' , 'value3' ] ) ;
625
+
626
+ expect ( handleGetMultipleStatesStub . calledOnce ) . to . be . true ;
627
+ expect ( handleGetMultipleStatesStub . firstCall . args ) . to . deep . equal ( [
628
+ '' ,
629
+ [ 'key1' , 'key2' , 'key3' ] ,
630
+ 'dummyChannelId' ,
631
+ 'dummyTxid'
632
+ ] ) ;
633
+ } ) ;
634
+
635
+ it ( 'should return empty array if no keys passed' , async ( ) => {
636
+ const handleGetMultipleStatesStub = sinon . stub ( ) . resolves ( [ ] ) ;
637
+
638
+ const stub = new Stub ( {
639
+ handleGetMultipleStates : handleGetMultipleStatesStub
640
+ } , 'dummyChannelId' , 'dummyTxid' , chaincodeInput ) ;
641
+
642
+ const result = await stub . getMultipleStates ( ) ;
643
+ expect ( result ) . to . deep . equal ( [ ] ) ;
644
+
645
+ expect ( handleGetMultipleStatesStub . calledOnce ) . to . be . true ;
646
+ expect ( handleGetMultipleStatesStub . firstCall . args ) . to . deep . equal ( [
647
+ '' ,
648
+ [ ] ,
649
+ 'dummyChannelId' ,
650
+ 'dummyTxid'
651
+ ] ) ;
652
+ } ) ;
653
+
654
+ it ( 'should throw error if handler rejects' , async ( ) => {
655
+ const handleGetMultipleStatesStub = sinon . stub ( ) . rejects ( new Error ( 'Something gone wrong' ) ) ;
656
+
657
+ const stub = new Stub ( {
658
+ handleGetMultipleStates : handleGetMultipleStatesStub
659
+ } , 'dummyChannelId' , 'dummyTxid' , chaincodeInput ) ;
660
+
661
+ await expect ( stub . getMultipleStates ( 'key1' ) ) . to . be . rejectedWith ( 'Something gone wrong' ) ;
662
+ } ) ;
663
+ } ) ;
664
+
615
665
describe ( 'putState' , ( ) => {
616
666
it ( 'should return handler.handlePutState' , async ( ) => {
617
667
const handlePutStateStub = sinon . stub ( ) . resolves ( 'some state' ) ;
0 commit comments