Skip to content

Commit 0958d62

Browse files
committed
refactor(coordinate): remove Coordinate data class
1 parent 4be45cb commit 0958d62

File tree

6 files changed

+12
-21
lines changed

6 files changed

+12
-21
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@ typings/
5858
.env
5959

6060
build/
61+
62+
.DS_Store

src/data/Coordinate.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/data/Location.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Record } from 'immutable';
22

3-
import Coordinate from './Coordinate';
4-
53
const defaults = {
64
name: '',
7-
coordinate: new Coordinate(),
5+
coordinate: {
6+
latitude: 0,
7+
longitude: 0,
8+
},
89
};
910

1011
export default class Location extends Record(defaults) {

src/services/translators/geocode/LocationTranslator.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Coordinate from '../../../data/Coordinate';
21
import Location from '../../../data/Location';
32
import Utilities from '../../Utilities';
43

@@ -19,10 +18,10 @@ export default class LocationTranslator {
1918
const location = json[this.GEOMETRY_ADDRESS_FIELD_NAME][this.LOCATION_FIELD_NAME];
2019
return new Location({
2120
name: json[this.FORMATTED_ADDRESS_FIELD_NAME],
22-
coordinate: new Coordinate({
21+
coordinate: {
2322
latitude: location[this.LATITUDE_FIELD_NAME],
2423
longitude: location[this.LONGITUDE_FIELD_NAME],
25-
}),
24+
},
2625
});
2726
}
2827

test/GeocodeServiceTest.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import chaiImmutable from 'chai-immutable';
44

55
import { List } from 'immutable';
66

7-
import Coordinate from '../src/data/Coordinate';
87
import GeocodeService from '../src/services/GeocodeService';
98
import Location from '../src/data/Location';
109

@@ -19,10 +18,10 @@ describe('Test Geocode Service', () => {
1918
const address = '25 first street cambridge ma';
2019
const location = new Location({
2120
name: '25 First St, Cambridge, MA 02141, USA',
22-
coordinate: new Coordinate({
21+
coordinate: {
2322
latitude: 42.369695,
2423
longitude: -71.07800569999999,
25-
}),
24+
},
2625
});
2726
const locations = List.of(location);
2827

test/services/translators/geocode/LocationTranslatorTest.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import chai from 'chai';
44
import sinon from 'sinon';
55
import sinonChai from 'sinon-chai';
66

7-
import Coordinate from '../../../../src/data/Coordinate';
87
import Location from '../../../../src/data/Location';
98

109
import LocationTranslator from '../../../../src/services/translators/geocode/LocationTranslator';
@@ -78,10 +77,10 @@ describe('Location Translation', () => {
7877
it('translates valid json', () => {
7978
const expected = new Location({
8079
name: 'foo',
81-
coordinate: new Coordinate({
80+
coordinate: {
8281
latitude: 1.234,
8382
longitude: 5.678,
84-
}),
83+
},
8584
});
8685
const isValid = sinon.stub(translator, 'isValid').returns(true);
8786
expect(translator.translate(json)).to.eql(expected);

0 commit comments

Comments
 (0)