Skip to content

Instantly share code, notes, and snippets.

@fearphage
Forked from jhartikainen/tests.js
Created May 13, 2016 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fearphage/aa512e0a04f1233ddf112740a850b0ba to your computer and use it in GitHub Desktop.
Save fearphage/aa512e0a04f1233ddf112740a850b0ba to your computer and use it in GitHub Desktop.
Example of stubbing a complex object
describe('something', function() {
beforeEach(function() {
this.getAttributeStub = sinon.stub(Xrm.Page, 'getAttribute');
});
afterEach(function() {
this.getAttributeStub.restore();
});
it('tests something', function() {
this.getAttributeStub.withArgs('name').returns({
getValue: function() { return 'something'; }
});
//test code here
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment