Skip to content

Instantly share code, notes, and snippets.

@Nepoxx
Last active December 10, 2015 17:05
Show Gist options
  • Select an option

  • Save Nepoxx/2d37d3d405173f0f7736 to your computer and use it in GitHub Desktop.

Select an option

Save Nepoxx/2d37d3d405173f0f7736 to your computer and use it in GitHub Desktop.

Revisions

  1. Nepoxx revised this gist Dec 10, 2015. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions sometest.spec.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ describe("when navigating to a route", function() {
    jasmine.Ajax.uninstall();
    })

    it("should have called the err function, making 'errored' to be 'false'", function() {
    it("should have called the err function, making 'errored' to be 'false'", function(done) {
    var errored = null;

    function err() {
    @@ -19,15 +19,19 @@ describe("when navigating to a route", function() {
    errored = false;
    }

    Thing.load().then(success).catch(err);
    Thing.load().then(success).catch(err)
    .then(function () {
    expect(errored).toBe(false);
    done();
    });

    jasmine.Ajax.requests.mostRecent().respondWith({
    status: 200,
    responseText: JSON.stringify({
    })
    });

    expect(errored).toBe(false);

    });

    });
  2. Danny Hadley revised this gist Dec 10, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sometest.spec.js
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ describe("when navigating to a route", function() {
    errored = false;
    }

    Thing.load().finally(finished);
    Thing.load().then(success).catch(err);

    jasmine.Ajax.requests.mostRecent().respondWith({
    status: 200,
  3. Danny Hadley revised this gist Dec 10, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sometest.spec.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ describe("when navigating to a route", function() {
    jasmine.Ajax.uninstall();
    })

    it("...", function() {
    it("should have called the err function, making 'errored' to be 'false'", function() {
    var errored = null;

    function err() {
  4. Danny Hadley revised this gist Dec 10, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion sometest.spec.js
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,6 @@ describe("when navigating to a route", function() {
    })
    });


    expect(errored).toBe(false);
    });

  5. Danny Hadley created this gist Dec 10, 2015.
    21 changes: 21 additions & 0 deletions Thing.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    var Thing = {
    load: function() {
    var resolve, reject;

    function finished() {
    resolve({})
    }

    function errored() {
    reject({});
    }

    function resolver(res, rej) {
    resolve = res;
    reject = rej;
    $.getJSON("/thing", {success: finished, error: errored});
    }

    return new Promise(resolver);
    }
    }
    34 changes: 34 additions & 0 deletions sometest.spec.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    describe("when navigating to a route", function() {

    beforeEach(function() {
    jasmine.Ajax.install();
    });

    afterEach(function() {
    jasmine.Ajax.uninstall();
    })

    it("...", function() {
    var errored = null;

    function err() {
    errored = true;
    }

    function success() {
    errored = false;
    }

    Thing.load().finally(finished);

    jasmine.Ajax.requests.mostRecent().respondWith({
    status: 200,
    responseText: JSON.stringify({
    })
    });


    expect(errored).toBe(false);
    });

    });