File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -408,7 +408,8 @@ function Sandbox(opts = {}) {
408408 const [ object , property , types ] = args ;
409409
410410 const isSpyingOnEntireObject =
411- typeof property === "undefined" && typeof object === "object" ;
411+ typeof property === "undefined" &&
412+ ( typeof object === "object" || typeof object === "function" ) ;
412413
413414 if ( isSpyingOnEntireObject ) {
414415 const ownMethods = collectOwnMethods ( spy ) ;
Original file line number Diff line number Diff line change @@ -1766,6 +1766,17 @@ describe("Sandbox", function () {
17661766
17671767 assert . isUndefined ( o . foo . callCount ) ;
17681768 } ) ;
1769+
1770+ it ( "restores all fields of a stubbed function" , function ( ) {
1771+ const sandbox = new Sandbox ( ) ;
1772+ const o = function ( ) { } ;
1773+ o . foo = function ( ) { } ;
1774+
1775+ sandbox . stub ( o ) ;
1776+ sandbox . restore ( ) ;
1777+
1778+ assert . isUndefined ( o . foo . callCount ) ;
1779+ } ) ;
17691780 } ) ;
17701781
17711782 describe ( "configurable sandbox" , function ( ) {
You can’t perform that action at this time.
0 commit comments