Created
November 19, 2011 14:52
-
-
Save searls/1378912 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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+")"; | |
} | |
}); |
This file contains hidden or 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
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