Skip to content

Commit

Permalink
Adding toString() to GeoPoint (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored Oct 30, 2017
1 parent d85f33e commit badcaae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ class GeoPoint {
return this._longitude;
}

/**
* Returns a string representation for this GeoPoint.
*
* @return {string} The string representation.
*/
toString() {
return `GeoPoint { latitude: ${this.latitude}, longitude: ${this
.longitude} }`;
}

/**
* Converts the GeoPoint to a google.type.LatLng proto.
* @private
Expand Down
8 changes: 6 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,12 @@ describe('snapshot_() method', function() {

// We specifically test the GeoPoint properties to ensure 100% test
// coverage.
assert.equal(50.1430847, data.geoPointValue.latitude);
assert.equal(-122.947778, data.geoPointValue.longitude);
assert.equal(data.geoPointValue.latitude, 50.1430847);
assert.equal(data.geoPointValue.longitude, -122.947778);
assert.equal(
data.geoPointValue.toString(),
'GeoPoint { latitude: 50.1430847, longitude: -122.947778 }'
);
}

beforeEach(function() {
Expand Down

0 comments on commit badcaae

Please # to comment.