@@ -905,7 +905,7 @@ describe("stub", function () {
905905 it ( "supersedes previous callThrough" , function ( ) {
906906 const obj = {
907907 fn ( ) {
908- return 'nooooo' ;
908+ return 'nooooo' ;
909909 }
910910 } ;
911911 createStub ( obj , 'fn' ) . callThrough ( ) . returnsThis ( ) ;
@@ -1240,7 +1240,7 @@ describe("stub", function () {
12401240 it ( "supersedes previous callThrough" , function ( ) {
12411241 const obj = {
12421242 fn ( ) {
1243- return 'nooooo' ;
1243+ return 'nooooo' ;
12441244 }
12451245 } ;
12461246 const stub = createStub ( obj , 'fn' ) . callThrough ( ) . callsArg ( 0 ) ;
@@ -1326,7 +1326,7 @@ describe("stub", function () {
13261326 it ( "supersedes previous callThrough" , function ( ) {
13271327 const obj = {
13281328 fn ( ) {
1329- return 'nooooo' ;
1329+ return 'nooooo' ;
13301330 }
13311331 } ;
13321332 const stub = createStub ( obj , 'fn' ) . callThrough ( ) . callsArgWith ( 0 , 'test' ) ;
@@ -1422,6 +1422,20 @@ describe("stub", function () {
14221422 assert ( callback . calledOnce ) ;
14231423 assert ( callback . calledOn ( this . fakeContext ) ) ;
14241424 } ) ;
1425+
1426+ it ( "supersedes previous callThrough" , function ( ) {
1427+ const obj = {
1428+ fn ( ) {
1429+ return 'nooooo' ;
1430+ }
1431+ } ;
1432+ createStub ( obj , 'fn' ) . callThrough ( ) . callsArgOn ( 0 , this . fakeContext ) ;
1433+ const callback = createStub ( ) . returns ( "return value" ) ;
1434+
1435+ assert . same ( obj . fn ( callback ) , "return value" ) ;
1436+ assert ( callback . calledOnce ) ;
1437+ assert ( callback . calledOn ( this . fakeContext ) ) ;
1438+ } ) ;
14251439 } ) ;
14261440
14271441 describe ( ".callsArgOnWith" , function ( ) {
@@ -1544,6 +1558,23 @@ describe("stub", function () {
15441558 assert ( callback . calledOnce ) ;
15451559 assert ( callback . calledWith ( object ) ) ;
15461560 } ) ;
1561+
1562+ it ( "supersedes previous callThrough" , function ( ) {
1563+ const obj = {
1564+ fn ( ) {
1565+ return 'nooooo' ;
1566+ }
1567+ } ;
1568+
1569+ const arg = 'hello' ;
1570+ createStub ( obj , 'fn' ) . callThrough ( ) . callsArgOnWith ( 1 , this . fakeContext , arg ) ;
1571+ const callback = createStub ( ) ;
1572+
1573+ obj . fn ( 1 , callback ) ;
1574+
1575+ assert ( callback . calledWith ( arg ) ) ;
1576+ assert ( callback . calledOn ( this . fakeContext ) ) ;
1577+ } ) ;
15471578 } ) ;
15481579
15491580 describe ( ".callsFake" , function ( ) {
@@ -1597,6 +1628,18 @@ describe("stub", function () {
15971628 assert ( fakeFn . called ) ;
15981629 assert ( returned === 5 ) ;
15991630 } ) ;
1631+
1632+ it ( "supersedes previous callThrough" , function ( ) {
1633+ const obj = {
1634+ fn ( ) {
1635+ return 'nooooo' ;
1636+ }
1637+ } ;
1638+
1639+ createStub ( obj , 'fn' ) . callThrough ( ) . callsFake ( ( ) => 'yeees' ) ;
1640+
1641+ assert . same ( obj . fn ( ) , 'yeees' ) ;
1642+ } ) ;
16001643 } ) ;
16011644
16021645 describe ( ".objectMethod" , function ( ) {
@@ -1893,6 +1936,20 @@ describe("stub", function () {
18931936 assert ( spy . calledWith , 2 ) ;
18941937 refute ( fakeFn . called ) ;
18951938 } ) ;
1939+
1940+ it ( "supersedes previous callThrough" , function ( ) {
1941+ const obj = {
1942+ fn ( ) {
1943+ return 1 ;
1944+ }
1945+ } ;
1946+
1947+ createStub ( obj , 'fn' ) . callThrough ( ) . yields ( 2 ) ;
1948+ const spy = createSpy ( ) ;
1949+ obj . fn ( spy ) ;
1950+
1951+ assert ( spy . calledWith , 2 ) ;
1952+ } ) ;
18961953 } ) ;
18971954
18981955 describe ( ".yieldsRight" , function ( ) {
@@ -2023,6 +2080,20 @@ describe("stub", function () {
20232080 assert ( spy . calledWith , 2 ) ;
20242081 refute ( fakeFn . called ) ;
20252082 } ) ;
2083+
2084+ it ( "supersedes previous callThrough" , function ( ) {
2085+ const obj = {
2086+ fn ( ) {
2087+ return 1 ;
2088+ }
2089+ } ;
2090+
2091+ createStub ( obj , 'fn' ) . callThrough ( ) . yieldsRight ( 2 ) ;
2092+ const spy = createSpy ( ) ;
2093+ obj . fn ( spy ) ;
2094+
2095+ assert ( spy . calledWith , 2 ) ;
2096+ } ) ;
20262097 } ) ;
20272098
20282099 describe ( ".yieldsOn" , function ( ) {
@@ -2180,6 +2251,20 @@ describe("stub", function () {
21802251 assert ( spy . calledWith , 2 ) ;
21812252 refute ( fakeFn . called ) ;
21822253 } ) ;
2254+
2255+ it ( "supersedes previous callThrough" , function ( ) {
2256+ const obj = {
2257+ fn ( ) {
2258+ return 1 ;
2259+ }
2260+ } ;
2261+
2262+ createStub ( obj , 'fn' ) . callThrough ( ) . yieldsOn ( this . fakeContext , 2 ) ;
2263+ const spy = createSpy ( ) ;
2264+ obj . fn ( spy ) ;
2265+
2266+ assert ( spy . calledWith , 2 ) ;
2267+ } ) ;
21832268 } ) ;
21842269
21852270 describe ( ".yieldsTo" , function ( ) {
@@ -2331,6 +2416,20 @@ describe("stub", function () {
23312416 assert ( callback . calledWith ( 2 ) ) ;
23322417 refute ( fakeFn . called ) ;
23332418 } ) ;
2419+
2420+ it ( "supersedes previous callThrough" , function ( ) {
2421+ const obj = {
2422+ fn ( ) {
2423+ return 1 ;
2424+ }
2425+ } ;
2426+
2427+ createStub ( obj , 'fn' ) . callThrough ( ) . yieldsTo ( "success" , 2 ) ;
2428+ const callback = createSpy ( ) ;
2429+ obj . fn ( { success : callback } ) ;
2430+
2431+ assert ( callback . calledWith , 2 ) ;
2432+ } ) ;
23342433 } ) ;
23352434
23362435 describe ( ".yieldsToOn" , function ( ) {
@@ -2517,6 +2616,20 @@ describe("stub", function () {
25172616 assert ( callback . calledWith ( 2 ) ) ;
25182617 refute ( fakeFn . called ) ;
25192618 } ) ;
2619+
2620+ it ( "supersedes previous callThrough" , function ( ) {
2621+ const obj = {
2622+ fn ( ) {
2623+ return 1 ;
2624+ }
2625+ } ;
2626+
2627+ createStub ( obj , 'fn' ) . callThrough ( ) . yieldsToOn ( "success" , this . fakeContext , 2 ) ;
2628+ const callback = createSpy ( ) ;
2629+ obj . fn ( { success : callback } ) ;
2630+
2631+ assert ( callback . calledWith ( 2 ) ) ;
2632+ } ) ;
25202633 } ) ;
25212634
25222635 describe ( ".withArgs" , function ( ) {
0 commit comments