Created
May 12, 2016 16:03
-
-
Save jeriley/27aac0549f559bf7702528d6f94d65c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildIt($){ | |
this.postIt = function(itemToChange){ | |
$.post('giggle', function(data){ | |
itemToChange.item = data.item; | |
}); | |
} | |
}; | |
// | |
describe("an example", function(){ | |
var existing = {}; | |
var results = {}; | |
var callback = {}; | |
beforeEach(function(){ | |
existing = new buildIt($); | |
spyOn($, "ajax").and.callFake(function(options){ | |
options.success({ | |
item: 'new data' | |
}); | |
results = options; | |
}); | |
callback = jasmine.createSpy(); | |
callback.item = "before"; | |
existing.postIt(callback); | |
}) | |
it("calls the right place", function(){ | |
console.log(results); | |
expect(results.url).toBe('giggle'); | |
}) | |
it("modifies stuff", function(){ | |
expect(callback.item).toBe('new data'); | |
}) | |
it("is a post", function(){ | |
expect(results.type).toBe('post'); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment