Skip to content

Instantly share code, notes, and snippets.

@jeriley
Created May 12, 2016 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeriley/27aac0549f559bf7702528d6f94d65c7 to your computer and use it in GitHub Desktop.
Save jeriley/27aac0549f559bf7702528d6f94d65c7 to your computer and use it in GitHub Desktop.
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