Skip to content

Instantly share code, notes, and snippets.

@searls
Created November 19, 2011 14:52
Show Gist options
  • Save searls/1378912 to your computer and use it in GitHub Desktop.
Save searls/1378912 to your computer and use it in GitHub Desktop.
window.MapPoint = Backbone.Model.extend({
initialize: function(attrs,options){
this.location = options.location;
},
locationDescription: function(){
var lat = this.location.get('lat'),
lng = this.location.get('lng');
return "("+lat+","+lng+")";
}
});
describe('MapPoint',function(){
var subject, location;
beforeEach(function(){
location = jasmine.createSpyObj('location',['get']);
subject = new MapPoint({},{ location: location });
});
describe("#locationDescription", function(){
var result,
LAT = 39.9292,
LNG = 14.1234;
beforeEach(function(){
location.get.when('lat').thenReturn(LAT);
location.get.when('lng').thenReturn(LNG);
result = subject.locationDescription();
});
it('prints it prettily', function(){
expect(result).toBe("("+LAT+","+LNG+")");
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment