You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was creating a test and I found that the isObjectWith function would be perfect for me since I did not want to test all attributes of my object, only the ones that concerned that specific test.
However, this object also had a sub-object with optional attributes (some of which I wanted to verify its presence, others I didn't), and this is what behaved differently than what I expected: It seems it will ignore attributes on the root of the object if they are not present, but won't ignore attributes of nested objects if they are not present.
I have created a minimal code example to ilustrate the problem:
import{It,Mock,Times}from'typemoq';functionmyFunc(object: {}){console.log('object',object);}constmyFuncMock=Mock.ofInstance(myFunc);myFuncMock.setup((m)=>m(It.isAny())).returns(()=>Promise.resolve());myFuncMock.object({x:0,a: {b: 0,c: 0}});// WorksmyFuncMock.verify((m)=>m(It.isObjectWith({x:0}),),Times.once());// WorksmyFuncMock.verify((m)=>m(It.isObjectWith({a: {b: 0,c: 0}}),),Times.once());// Does not work:myFuncMock.verify((m)=>m(It.isObjectWith({a: {b: 0}}),),Times.once());
Is this the expected behavior?
Also, thanks in advance for your attention and for the great library =]
The text was updated successfully, but these errors were encountered:
I was creating a test and I found that the isObjectWith function would be perfect for me since I did not want to test all attributes of my object, only the ones that concerned that specific test.
However, this object also had a sub-object with optional attributes (some of which I wanted to verify its presence, others I didn't), and this is what behaved differently than what I expected: It seems it will ignore attributes on the root of the object if they are not present, but won't ignore attributes of nested objects if they are not present.
I have created a minimal code example to ilustrate the problem:
Is this the expected behavior?
Also, thanks in advance for your attention and for the great library =]
The text was updated successfully, but these errors were encountered: