I am using Jasmine to test if certain objects are created and methods are called on them.  I have a jQuery widget that creates flipcounter objects and calls the setValue method on them.  The code for flipcounter is here: https://bitbucket.org/cnanney...
Given the following code snippet, how would you create a Jasmine spyOn test to confirm that doSomething gets called when you run MyFunction?  function MyFunction() {     var foo = new MyCoolObject();     foo.doSomething(); };   Here's what my tes...
There is custom event fired in the FooView ..  // views/foo_view.js  this.trigger("something:happened");   The associated FooController binds a handler to take care of the event ...  // controller/foo_controller.js  initialize: function() {...
I'm writing specs for different test cases for Jasmine and QUnit to compare them and they looked the same before I needed to write a test to check if an event is binded to an element.  Event binding looks like  $('.page').live('click&...
I'm trying to spy window.document with sinon.js. What I do is this:  var document = {     getElementById = function() {} }  sinon.spy(document, "getElementById").withArgs("foo").returnValues = ["bar"];   What I expect from...
I am having trouble asserting that my filter has been called after a promise has been returned.  This code is called from a controller which then pulls the data to filter from a http GET service:  getPermissions(){     return this.DataService.getPerm...
How to test if an anonymous function was passed as parameter in a spy function of sinon.js? Imagine a function like that.  function myFunction(){     //do stuff     otherobj.anotherFunc({myobj: 'value'}, function(){ console.log('test'...
I am trying to spy on a global function e.g.  function foo() {  }   but the below test is failing, how to do that      var spy = sinon.spy(foo);     foo();     expect(spy.callCount).to.equal(1);   ** EDIT **  If I do it like below then it works...
I am trying to spy on $.ajax in Jasmine 2.0 tests. Here is a simplified example (TypeScript) showing my scenario:  describe("first test", () => {     var deferred = jQuery.Deferred();     spyOn($, "ajax").and.callFake((uri: string,...
My component has the following function:    updateTransactions() {     let notes = this.createNotes()      let delTransactions = this.createDelTransactions()     this.noteService.createNote(notes[0])     this.noteService.getNoteCreated().subscribe((r...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.