Jasmine.Clock doesn't work when passing strings to setTimeout #245

Closed
eskimoblood opened this Issue Jun 23, 2012 · 1 comment

Comments

Projects
None yet
2 participants

When passing a String to setTimeout Jasmine.Clock fails, cause it doesn't check if the passed argument is an function or an string:

dummy_method = function(callback) {
  fire_callback = function() {
    callback();
  }
  setTimeout("fire_callback()", 1000);
}

describe "jQuery.fn.countdown", ->
  beforeEach () ->
    jasmine.Clock.useMock()
  it 'should fireup the callback', ->
    countdown_callback = jasmine.createSpy('countdown_callback');

    dummy_method(countdown_callback)
    jasmine.Clock.tick(1001)
    expect(countdown_callback).toHaveBeenCalled()

This test failed. I am aware that passing a string instead of a function is bad style but its valid and so the test should pass.

Contributor

infews commented May 27, 2013

Please see this story in our backlog. We agree that eval'd strings should be usable since the normal interface supports them.

Closing.

@infews infews closed this May 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment