Git Product home page Git Product logo

jasmine-signals's People

Contributors

adamnowotny avatar gavjackson avatar robinjmurphy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jasmine-signals's Issues

toHaveBeenDispatchedWith passes if first argument matches even if the rest do not

With some test code that dispatches one variable, such as:
function lock() { lockChanged.dispatch( true ); }

Test code
var lockChangedSignalSpy = spyOnSignal( lockChanged ); lock(); expect( lockChangedSignalSpy ).toHaveBeenDispatchedWith( true ); lock(); expect( lockChangedSignalSpy ).toHaveBeenDispatchedWith( true, 'arf' );

Both expects pass, while the second one should fail, as 'arf' was not dispatched. If 'arf' comes before true, it does fail and It does report that it was called twice with only true both times.

ForEach IE8 and below

Thank you for this helpful plugin! :) While using it we encountered a browser issue:

In jasmine-signals.js, around line 156 there is this function in the afterEach:

afterEach(function () {
    spies.forEach(function (d) {
        d.stop();
    });
    spies = [];
});

It assumes that Array has a forEach function. Since spies appears to always be an array, this small change not only is faster due to no function calls, but works in older browsers, which still benefit from testing.

afterEach(function () {
    for (var spiesIndex = 0, length = spies.length; spiesIndex < length; spiesIndex++) {
        spies[spiesIndex].stop();
    }
    spies = [];
});

Should jasmine-signals work with grunt-jasmine?

In this test I test that a signal is dispatched, in a normal way..

it("handleSetupLoaded should dispatch a 'setupComplete' Signal and pass the result", function() {

    var event = {
        result: "mock setup data"
    };

    //stubs also let us ignore function calls we are not testing in this unit
    sinon.stub(this.class, "loadGameAssets");

    spyOnSignal(this.class.setupComplete);

    this.class.handleSetupLoaded(event);

    expect(this.class.setupComplete).toHaveBeenDispatchedWith("mock setup data");
});

When I run the test in the browser SpecRunner.html, it passes, but in phantomjs using grunt-jasmine)
it fails with the following error:

TypeError: 'undefined' is not an object (evaluating 'new jasmine.signals.SignalSpy') in file:///Users/hayesmaker/Workspace/HTML5/kingkong/Trunk/public/javascripts/vendor/jasmine-signals/jasmine-signals.js (line 11)

jasmine.any isn't working with these matchers

Why would this test fail?

var spy = spyOnSignal(controller.initialCardsDealt);
controller.initialCardsDealt.dispatch([], []);
expect(spy).toHaveBeenDispatchedWith(jasmine.any[Object],jasmine.any[Object]);

Fails:

Expected [Signal active:true numListeners:1] to have been dispatched with (,) but was with (,)
Error: Expected [Signal active:true numListeners:1] to have been dispatched with (,) but was with (,)
at new jasmine.ExpectationResult (http://localhost:63342/solitaire-showdown/public/js/test/jasmine/lib/jasmine/jasmine.js:114:32)
at null.toHaveBeenDispatchedWith (http://localhost:63342/solitaire-showdown/public/js/test/jasmine/lib/jasmine/jasmine.js:1235:29)
at null. (http://localhost:63342/solitaire-showdown/public/js/test/jasmine/spec/hayesmaker/solitaire/game/components/rulesSpec.js:48:25)
at jasmine.Block.execute (http://localhost:63342/solitaire-showdown/public/js/test/jasmine/lib/jasmine/jasmine.js:1064:17)
at jasmine.Queue.next_ (http://localhost:63342/solitaire-showdown/public/js/test/jasmine/lib/jasmine/jasmine.js:2096:31)
at jasmine.Queue.start (http://localhost:63342/solitaire-showdown/public/js/test/jasmine/lib/jasmine/jasmine.js:2049:8)
at jasmine.Spec.execute (http://localhost:63342/solitaire-showdown/public/js/test/jasmine/lib/jasmine/jasmine.js:2376:14)
at jasmine.Queue.next_ (http://localhost:63342/solitaire-showdown/public/js/test/jasmine/lib/jasmine/jasmine.js:2096:31)
at jasmine.Queue.start (http://localhost:63342/solitaire-showdown/public/js/test/jasmine/lib/jasmine/jasmine.js:2049:8)
at jasmine.Suite.execute (http://localhost:63342/solitaire-showdown/public/js/test/jasmine/lib/jasmine/jasmine.js:2521:14)

Should jasmine-signals work with grunt-jasmine?

In this test I test that a signal is dispatched, in a normal way..

it("handleSetupLoaded should dispatch a 'setupComplete' Signal and pass the result", function() {

    var event = {
        result: "mock setup data"
    };

    //stubs also let us ignore function calls we are not testing in this unit
    sinon.stub(this.class, "loadGameAssets");

    spyOnSignal(this.class.setupComplete);

    this.class.handleSetupLoaded(event);

    expect(this.class.setupComplete).toHaveBeenDispatchedWith("mock setup data");
});

When I run the test in the browser SpecRunner.html, it passes, but in phantomjs using grunt-jasmine)
it fails with the following error:

TypeError: 'undefined' is not an object (evaluating 'new jasmine.signals.SignalSpy') in file:///Users/hayesmaker/Workspace/HTML5/kingkong/Trunk/public/javascripts/vendor/jasmine-signals/jasmine-signals.js (line 11)

whats happened to the reset method?

I've just downloaded the latest version of jasmine-signals and noticed that you have removed the reset() method of the signal spy.

    namespace.SignalSpy.prototype.reset = function () {
        this.count = 0;
    };

Has this been deprecated? I cannot find a replacement method, can you add it back in, I did find it quite useful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.