@@ -1314,32 +1314,45 @@ describe('moduleMocker', () => {
13141314
13151315 it ( 'supports restoring a spy' , ( ) => {
13161316 let methodOneCalls = 0 ;
1317+ let methodTwoCalls = 0 ;
13171318 const obj = {
13181319 methodOne ( ) {
13191320 methodOneCalls ++ ;
13201321 } ,
1322+ methodTwo ( ) {
1323+ methodTwoCalls ++ ;
1324+ } ,
13211325 } ;
13221326
13231327 const spy1 = moduleMocker . spyOn ( obj , 'methodOne' ) ;
1328+ const spy2 = moduleMocker . spyOn ( obj , 'methodTwo' ) ;
13241329
13251330 obj . methodOne ( ) ;
1331+ obj . methodTwo ( ) ;
13261332
1327- // The spy and the original function got called.
1333+ // Both spies and both original functions got called.
13281334 expect ( methodOneCalls ) . toBe ( 1 ) ;
1335+ expect ( methodTwoCalls ) . toBe ( 1 ) ;
13291336 expect ( spy1 . mock . calls ) . toHaveLength ( 1 ) ;
1337+ expect ( spy2 . mock . calls ) . toHaveLength ( 1 ) ;
13301338
13311339 expect ( moduleMocker . isMockFunction ( obj . methodOne ) ) . toBe ( true ) ;
1340+ expect ( moduleMocker . isMockFunction ( obj . methodTwo ) ) . toBe ( true ) ;
13321341
13331342 spy1 . mockRestore ( ) ;
13341343
1335- // After restoring the spy , the method is not mock function.
1344+ // After restoring `spy1` , the method is not mock function.
13361345 expect ( moduleMocker . isMockFunction ( obj . methodOne ) ) . toBe ( false ) ;
1346+ expect ( moduleMocker . isMockFunction ( obj . methodTwo ) ) . toBe ( true ) ;
13371347
13381348 obj . methodOne ( ) ;
1349+ obj . methodTwo ( ) ;
13391350
1340- // After restoring the spy only the real method bumps its call count, not the spy.
1351+ // After restoring `spy1` only the real method bumps its call count, not the spy.
13411352 expect ( methodOneCalls ) . toBe ( 2 ) ;
1353+ expect ( methodTwoCalls ) . toBe ( 2 ) ;
13421354 expect ( spy1 . mock . calls ) . toHaveLength ( 0 ) ;
1355+ expect ( spy2 . mock . calls ) . toHaveLength ( 2 ) ;
13431356 } ) ;
13441357
13451358 it ( 'supports restoring all spies' , ( ) => {
@@ -1521,29 +1534,42 @@ describe('moduleMocker', () => {
15211534
15221535 it ( 'supports restoring a spy' , ( ) => {
15231536 let methodOneCalls = 0 ;
1537+ let methodTwoCalls = 0 ;
15241538 const obj = {
15251539 get methodOne ( ) {
15261540 return function ( ) {
15271541 methodOneCalls ++ ;
15281542 } ;
15291543 } ,
1544+ get methodTwo ( ) {
1545+ return function ( ) {
1546+ methodTwoCalls ++ ;
1547+ } ;
1548+ } ,
15301549 } ;
15311550
15321551 const spy1 = moduleMocker . spyOn ( obj , 'methodOne' , 'get' ) ;
1552+ const spy2 = moduleMocker . spyOn ( obj , 'methodTwo' , 'get' ) ;
15331553
15341554 obj . methodOne ( ) ;
1555+ obj . methodTwo ( ) ;
15351556
1536- // The spy and the original function are called.
1557+ // Both spies and both original functions got called.
15371558 expect ( methodOneCalls ) . toBe ( 1 ) ;
1559+ expect ( methodTwoCalls ) . toBe ( 1 ) ;
15381560 expect ( spy1 . mock . calls ) . toHaveLength ( 1 ) ;
1561+ expect ( spy2 . mock . calls ) . toHaveLength ( 1 ) ;
15391562
15401563 spy1 . mockRestore ( ) ;
15411564
15421565 obj . methodOne ( ) ;
1566+ obj . methodTwo ( ) ;
15431567
1544- // After restoring the spy only the real method bumps its call count, not the spy.
1568+ // After restoring `spy1` only the real method bumps its call count, not the spy.
15451569 expect ( methodOneCalls ) . toBe ( 2 ) ;
1570+ expect ( methodTwoCalls ) . toBe ( 2 ) ;
15461571 expect ( spy1 . mock . calls ) . toHaveLength ( 0 ) ;
1572+ expect ( spy2 . mock . calls ) . toHaveLength ( 2 ) ;
15471573 } ) ;
15481574
15491575 it ( 'supports restoring all spies' , ( ) => {
@@ -1653,30 +1679,43 @@ describe('moduleMocker', () => {
16531679
16541680 it ( 'supports restoring a spy on the prototype chain' , ( ) => {
16551681 let methodOneCalls = 0 ;
1682+ let methodTwoCalls = 0 ;
16561683 const prototype = {
16571684 get methodOne ( ) {
16581685 return function ( ) {
16591686 methodOneCalls ++ ;
16601687 } ;
16611688 } ,
1689+ get methodTwo ( ) {
1690+ return function ( ) {
1691+ methodTwoCalls ++ ;
1692+ } ;
1693+ } ,
16621694 } ;
16631695 const obj = Object . create ( prototype , { } ) ;
16641696
16651697 const spy1 = moduleMocker . spyOn ( obj , 'methodOne' , 'get' ) ;
1698+ const spy2 = moduleMocker . spyOn ( obj , 'methodTwo' , 'get' ) ;
16661699
16671700 obj . methodOne ( ) ;
1701+ obj . methodTwo ( ) ;
16681702
1669- // The spy and the original function are called.
1703+ // Both spies and both original functions got called.
16701704 expect ( methodOneCalls ) . toBe ( 1 ) ;
1705+ expect ( methodTwoCalls ) . toBe ( 1 ) ;
16711706 expect ( spy1 . mock . calls ) . toHaveLength ( 1 ) ;
1707+ expect ( spy2 . mock . calls ) . toHaveLength ( 1 ) ;
16721708
16731709 spy1 . mockRestore ( ) ;
16741710
16751711 obj . methodOne ( ) ;
1712+ obj . methodTwo ( ) ;
16761713
1677- // After restoring the spy only the real method bumps its call count, not the spy.
1714+ // After restoring `spy1` only the real method bumps its call count, not the spy.
16781715 expect ( methodOneCalls ) . toBe ( 2 ) ;
1716+ expect ( methodTwoCalls ) . toBe ( 2 ) ;
16791717 expect ( spy1 . mock . calls ) . toHaveLength ( 0 ) ;
1718+ expect ( spy2 . mock . calls ) . toHaveLength ( 2 ) ;
16801719 } ) ;
16811720
16821721 it ( 'supports restoring all spies on the prototype chain' , ( ) => {
0 commit comments