1212 * information: "Portions copyright [year] [name of copyright owner]".
1313 *
1414 * Copyright 2016 ForgeRock AS.
15+ * Portions copyright 2025 3A Systems LLC.
1516 */
1617
1718define ( [
@@ -32,14 +33,14 @@ define([
3233
3334 testModel . url = "/crestResource" ;
3435
35- sinon . stub ( ServiceInvoker , "restCall" , function ( opts ) {
36+ sinon . stub ( ServiceInvoker , "restCall" ) . callsFake ( function ( opts ) {
3637 return $ . Deferred ( ) . resolve ( _ . extend ( JSON . parse ( opts . data ) , {
3738 "_id" : 1 ,
3839 "_rev" : 1
3940 } ) ) ;
4041 } ) ;
4142
42- testModel . save ( newRecord ) . then ( function ( ) {
43+ return testModel . save ( newRecord ) . then ( function ( ) {
4344 restCallArg = ServiceInvoker . restCall . args [ 0 ] [ 0 ] ; // first invocation, first argument
4445 assert . equal ( testModel . id , 1 , "Newly-created model has id from backend" ) ;
4546 assert . equal ( restCallArg . url , "/crestResource?_action=create&" , "correct url used to create model" ) ;
@@ -60,21 +61,21 @@ define([
6061 testModel . url = "/crestResource" ;
6162 testModel . id = "myCustomId" ;
6263
63- sinon . stub ( ServiceInvoker , "restCall" , function ( opts ) {
64+ sinon . stub ( ServiceInvoker , "restCall" ) . callsFake ( function ( opts ) {
6465 return $ . Deferred ( ) . resolve ( _ . extend ( JSON . parse ( opts . data ) , {
6566 "_rev" : 1
6667 } ) ) ;
6768 } ) ;
6869
69- testModel . save ( newRecord ) . then ( function ( ) {
70+ return testModel . save ( newRecord ) . then ( function ( ) {
7071 restCallArg = ServiceInvoker . restCall . args [ 0 ] [ 0 ] ; // first invocation, first argument
7172 assert . equal ( testModel . get ( "_rev" ) , 1 , "Model has new rev from backend" ) ;
7273 assert . equal ( restCallArg . url , "/crestResource/myCustomId?" , "correct url used to create model" ) ;
7374 assert . equal ( restCallArg . headers [ "If-None-Match" ] , "*" , "correct revision header provided" ) ;
7475 assert . equal ( restCallArg . type , "PUT" , "correct method used to create model" ) ;
7576
7677 ServiceInvoker . restCall . restore ( ) ;
77- } )
78+ } ) ;
7879 } ) ;
7980
8081 QUnit . test ( "read operation" , function ( assert ) {
@@ -84,15 +85,15 @@ define([
8485 testModel . url = "/crestResource" ;
8586 testModel . id = 1 ;
8687
87- sinon . stub ( ServiceInvoker , "restCall" , function ( ) {
88+ sinon . stub ( ServiceInvoker , "restCall" ) . callsFake ( function ( ) {
8889 return $ . Deferred ( ) . resolve ( {
8990 "_id" : 1 ,
9091 "_rev" : 1 ,
9192 "name" : "foo"
9293 } ) ;
9394 } ) ;
9495
95- testModel . fetch ( ) . then ( function ( ) {
96+ return testModel . fetch ( ) . then ( function ( ) {
9697 restCallArg = ServiceInvoker . restCall . args [ 0 ] [ 0 ] ; // first invocation, first argument
9798 assert . equal ( testModel . get ( "name" ) , "foo" , "example data populated from fetch call" ) ;
9899 assert . equal ( testModel . get ( "_rev" ) , 1 , "revision populated from fetch call" ) ;
@@ -128,13 +129,13 @@ define([
128129
129130 testModel . url = "/crestResource" ;
130131
131- sinon . stub ( ServiceInvoker , "restCall" , function ( opts ) {
132+ sinon . stub ( ServiceInvoker , "restCall" ) . callsFake ( function ( opts ) {
132133 return $ . Deferred ( ) . resolve ( _ . extend ( JSON . parse ( opts . data ) , {
133134 "_rev" : 2
134135 } ) ) ;
135136 } ) ;
136137
137- testModel . save ( ) . then ( function ( ) {
138+ return testModel . save ( ) . then ( function ( ) {
138139 restCallArg = ServiceInvoker . restCall . args [ 0 ] [ 0 ] ; // first invocation, first argument
139140 assert . equal ( testModel . get ( "_rev" ) , 2 , "Model has new rev from backend" ) ;
140141 assert . equal ( restCallArg . url , "/crestResource/1?" , "correct url used to update model" ) ;
@@ -156,11 +157,11 @@ define([
156157
157158 testModel . url = "/crestResource" ;
158159
159- sinon . stub ( ServiceInvoker , "restCall" , function ( opts ) {
160+ sinon . stub ( ServiceInvoker , "restCall" ) . callsFake ( function ( ) {
160161 return $ . Deferred ( ) . resolve ( ) ;
161162 } ) ;
162163
163- testModel . destroy ( ) . then ( function ( ) {
164+ return testModel . destroy ( ) . then ( function ( ) {
164165 restCallArg = ServiceInvoker . restCall . args [ 0 ] [ 0 ] ; // first invocation, first argument
165166 assert . equal ( restCallArg . url , "/crestResource/1?" , "correct url used to delete model" ) ;
166167 assert . equal ( restCallArg . type , "DELETE" , "correct method used to DELETE model" ) ;
@@ -180,11 +181,11 @@ define([
180181
181182 testModel . url = "/crestResource" ;
182183
183- sinon . stub ( ServiceInvoker , "restCall" , function ( opts ) {
184+ sinon . stub ( ServiceInvoker , "restCall" ) . callsFake ( function ( ) {
184185 return $ . Deferred ( ) . resolve ( ) ;
185186 } ) ;
186187
187- testModel . save ( { "foo" : "baz" } , { patch : true } ) . then ( function ( ) {
188+ return testModel . save ( { "foo" : "baz" } , { patch : true } ) . then ( function ( ) {
188189 restCallArg = ServiceInvoker . restCall . args [ 0 ] [ 0 ] ; // first invocation, first argument
189190
190191 assert . equal ( restCallArg . url , "/crestResource/1?" , "correct url used to patch model" ) ;
0 commit comments