Guest User

Untitled

a guest
Oct 18th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. sandbox.stub(Cars, "findOne",
  2. () => {return car1 });
  3.  
  4. Cars.find().fetch()
  5.  
  6. sandbox.stub(Cars, "find", () => {
  7. return {
  8. fetch: sinon.stub().returns(anything);
  9. };
  10. });
  11.  
  12. //set up stub and spy
  13. const valSpy = sandbox.spy();
  14. const jQueryStub = sandbox
  15. .stub($.prototype, "find") // this prototype is important
  16. .withArgs("input[name=email]")
  17. .returns({ val: valSpy });
  18.  
  19. // call function under test
  20. learnerAlreadyAccepted(inviteDoc);
  21.  
  22. // check expectations
  23. expect(jQueryStub).to.have.been.called; // not really necessary
  24. expect(valSpy).to.have.been.calledWith("");
  25.  
  26. learnerAlreadyAccepted = function(doc) {
  27. $("form").find("input[name=email]").val("");
  28. }
Add Comment
Please, Sign In to add comment