-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The Great Tests Crusade #98
Merged
miguelcobain
merged 7 commits into
gabesmed:ember-cli-es6
from
miguelcobain:ember-cli-es6
Mar 19, 2015
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c4d30b8
collection, container, marker, tile, collection bounds and draggable
miguelcobain 207cc9c
ported remaining tests
miguelcobain ee69703
added util tests
miguelcobain 5417377
added failing test for complex popup view
miguelcobain c6d9f2e
update yuidoc classes documentation
miguelcobain fe47fe3
popup fix
gabesmed 7772f62
Merge pull request #1 from gabesmed/popupfix
miguelcobain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ArrayPathLayer from './array-path'; | ||
import BoundsMixin from '../mixins/bounds'; | ||
|
||
/** | ||
`EmberLeaflet.PathBoundsLayer` is a base class that takes a list | ||
of locations and computed the bounding box. | ||
|
||
@class PathBoundsLayer | ||
@namespace EmberLeaflet | ||
@extends EmberLeaflet.ArrayPathLayer | ||
*/ | ||
export default ArrayPathLayer.extend(BoundsMixin, {}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default { | ||
nyc: L.latLng(40.713282, -74.006978), | ||
sf: L.latLng(37.77493, -122.419415), | ||
chicago: L.latLng(41.878114, -87.629798), | ||
paris: L.latLng(48.856614, 2.352222), | ||
london: L.latLng(51.511214, -0.119824), | ||
newdelhi: L.latLng(28.635308, 77.22496) | ||
}; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import Ember from 'ember'; | ||
import BoundsPathLayer from '../../../layers/bounds-path'; | ||
import { module, test } from 'qunit'; | ||
|
||
var geometry, locations; | ||
var n = [-15.780148, -47.92917], | ||
w = [-15.782102, -47.936869], | ||
s = [-15.786108, -47.931933], | ||
e = [-15.783423, -47.924638]; | ||
|
||
module('BoundsPathLayer with location property', { | ||
beforeEach: function() { | ||
locations = Ember.A([ | ||
Ember.Object.create({lastSeenAt: n}), | ||
Ember.Object.create({lastSeenAt: w}), | ||
Ember.Object.create({lastSeenAt: s}), | ||
Ember.Object.create({lastSeenAt: null}), | ||
Ember.Object.create({lastSeenAt: e}) | ||
]); | ||
geometry = BoundsPathLayer.create({ | ||
content: locations, | ||
locationProperty: 'lastSeenAt' | ||
}); | ||
} | ||
}); | ||
|
||
test('bounds initializes ok', function(assert) { | ||
var bounds = geometry.get('bounds'); | ||
assert.ok(bounds, 'bounds should be initialized'); | ||
assert.equal(bounds.getSouth(), s[0]); | ||
assert.equal(bounds.getNorth(), n[0]); | ||
assert.equal(bounds.getWest(), w[1]); | ||
assert.equal(bounds.getEast(), e[1]); | ||
}); | ||
|
||
test('add an object updates bounds', function(assert) { | ||
var e2 = [-15.782515, -47.914295]; // further east | ||
locations.pushObject(Ember.Object.create({lastSeenAt: e2})); | ||
assert.equal(geometry.get('bounds').getEast(), e2[1]); | ||
}); | ||
|
||
test('remove an object updates bounds', function(assert) { | ||
Ember.run(function() { locations.replace(3, 2); }); | ||
// now northernmost (first) point is most eastward | ||
assert.equal(geometry.get('bounds').getEast(), n[1]); | ||
}); | ||
|
||
test('update a location updates bound', function(assert) { | ||
locations[1].set('lastSeenAt', e); | ||
// Now bounds don't extend as far west | ||
assert.equal(geometry.get('bounds').getWest(), s[1]); | ||
}); | ||
|
||
test('clear locations empties bounds', function(assert) { | ||
Ember.run(function() { locations.clear(); }); | ||
assert.equal(geometry.get('bounds'), null); | ||
}); | ||
|
||
test('nullify locations empties bounds', function(assert) { | ||
Ember.run(function() { geometry.set('locations', null); }); | ||
assert.equal(geometry.get('bounds'), null); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Ember from 'ember'; | ||
import BoundsPathLayer from '../../../layers/bounds-path'; | ||
import { module, test } from 'qunit'; | ||
|
||
var geometry, locations; | ||
var n = [-15.780148, -47.92917], | ||
w = [-15.782102, -47.936869], | ||
s = [-15.786108, -47.931933], | ||
e = [-15.783423, -47.924638]; | ||
|
||
module('BoundsPathLayer', { | ||
beforeEach: function() { | ||
locations = Ember.A([ | ||
L.latLng(n), L.latLng(w), L.latLng(s), null, L.latLng(e) | ||
]); | ||
geometry = BoundsPathLayer.create({ | ||
locations: locations | ||
}); | ||
} | ||
}); | ||
|
||
test('bounds initializes ok', function(assert) { | ||
var bounds = geometry.get('bounds'); | ||
assert.ok(bounds, 'bounds should be initialized'); | ||
assert.equal(bounds.getSouth(), s[0]); | ||
assert.equal(bounds.getNorth(), n[0]); | ||
assert.equal(bounds.getWest(), w[1]); | ||
assert.equal(bounds.getEast(), e[1]); | ||
}); | ||
|
||
test('add an object updates bounds', function(assert) { | ||
var e2 = [-15.782515, -47.914295]; // further east | ||
locations.pushObject(L.latLng(e2)); | ||
assert.equal(geometry.get('bounds').getEast(), e2[1]); | ||
}); | ||
|
||
test('remove an object updates bounds', function(assert) { | ||
locations.splice(3, 2); | ||
// now northernmost (first) point is most eastward | ||
assert.equal(geometry.get('bounds').getEast(), n[1]); | ||
}); | ||
|
||
test('clear locations empties bounds', function(assert) { | ||
locations.clear(); | ||
assert.equal(geometry.get('bounds'), null); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import Ember from 'ember'; | ||
import CircleLayer from '../../../layers/circle'; | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import locationsEqual from '../../helpers/locations-equal'; | ||
import locations from '../../helpers/locations'; | ||
|
||
var content, circle, component; | ||
|
||
moduleForComponent('ember-leaflet', 'CircleLayer', { | ||
beforeEach: function() { | ||
content = Ember.Object.create({location: locations.sf, radius:10}); | ||
circle = CircleLayer.create({ | ||
content: content | ||
}); | ||
|
||
component = this.subject(); | ||
component.set('childLayers', [circle]); | ||
this.render(); | ||
} | ||
}); | ||
|
||
test('circle is created', function(assert) { | ||
assert.ok(!!circle._layer); | ||
assert.equal(circle._layer._map, component._layer); | ||
}); | ||
|
||
test('locations match', function(assert) { | ||
var _layerLocation = circle._layer.getLatLng(); | ||
locationsEqual(assert, _layerLocation, locations.sf); | ||
var locationLatLng = circle.get('location'); | ||
locationsEqual(assert, locationLatLng, locations.sf); | ||
}); | ||
|
||
test('radius match', function(assert) { | ||
var _layerRadius = circle._layer.getRadius(); | ||
assert.equal(_layerRadius, 10); | ||
var locationRadius = circle.get('radius'); | ||
assert.equal(locationRadius, 10); | ||
}); | ||
|
||
test('set location to null clears circle', function(assert) { | ||
circle.set('location', null); | ||
assert.equal(circle._layer, null); | ||
assert.equal(content.get('location'), null); | ||
}); | ||
|
||
test('move location in content moves circle', function(assert) { | ||
content.set('location', locations.chicago); | ||
locationsEqual(assert, circle.get('location'), locations.chicago); | ||
locationsEqual(assert, circle._layer.getLatLng(), locations.chicago); | ||
}); | ||
|
||
test('move location to array moves circle', function(assert) { | ||
content.set('location', [locations.sf.lat, locations.sf.lng]); | ||
assert.deepEqual(circle.get('location'), [locations.sf.lat, locations.sf.lng], | ||
'location is still array'); | ||
locationsEqual(assert, circle._layer.getLatLng(), locations.sf, | ||
'but circle center is converted to latLng before going to leatlet'); | ||
}); | ||
|
||
test('change radius in content changes circle radius', function(assert) { | ||
content.set('radius', 20); | ||
assert.equal(circle.get('radius'), 20); | ||
assert.equal(circle._layer.getRadius(), 20); | ||
}); | ||
|
||
test('nullify location in content clears circle', function(assert) { | ||
content.set('location', null); | ||
assert.equal(circle.get('location'), null); | ||
assert.equal(circle._layer, null); | ||
}); | ||
|
||
test('circle with null location should not create leaflet obj', function(assert) { | ||
var newCircle = CircleLayer.create({ | ||
content: {location: null, radius: 10} | ||
}); | ||
component.pushObject(newCircle); | ||
assert.equal(newCircle._layer, null); | ||
}); | ||
|
||
test('circle with null radius should create leaflet obj', function(assert) { | ||
var newCircle = CircleLayer.create({ | ||
content: {location: locations.sf, radius: null} | ||
}); | ||
Ember.run(function() { | ||
component.pushObject(newCircle); | ||
}); | ||
assert.ok(newCircle._layer); | ||
assert.equal(newCircle._layer._mRadius, null); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a delicate part.
Simple tests are passing, but I would like to know if there is a better way to do this.