Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of stubbing a complex object
describe('something', function() {
var oldXrm;
beforeEach(function() {
oldXrm = Xrm;
Xrm = {
Page: {
getAttribute: sinon.stub()
}
};
});
afterEach(function() {
Xrm = oldXrm;
});
it('tests something', function() {
var fakeAttribute = {
getValue: function() { return 'something'; }
};
Xrm.Page.getAttribute.withArgs('name').returns(fakeAttribute);
//test code here
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment