Skip to content
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

Get neglected tests to pass in Chrome #436

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"iron-selector": "PolymerElements/iron-selector#1 - 2"
},
"devDependencies": {
"web-component-tester": "^6.0.0",
"web-component-tester": "^6.5.0",
"iron-component-page": "PolymerElements/iron-component-page#1 - 2"
},
"variants": {
Expand Down
13 changes: 12 additions & 1 deletion google-map-poly.html
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@
observer: '_geodesicChanged'
},

/**
* When true, the poly is not visible.
*/
hidden: {
type: Boolean
},

/**
* If the path is not closed, the icons to be rendered along the polyline.
*/
Expand Down Expand Up @@ -351,7 +358,11 @@

attached: function() {
// If element is added back to DOM, put it back on the map.
this.poly && this.poly.setMap(this.map);
if (this.poly) {
this.poly.setMap(this.map);
this.poly.setVisible(!this.hidden);
this.poly.setDraggable(this.draggable);
}
},

// Attribute/property change watchers.
Expand Down
14 changes: 11 additions & 3 deletions test/google-map-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
var map2 = document.querySelector('#map2');
var map3 = document.querySelector('#map3');

var whenReady = function(m, cb) {
if (m.map) {
cb();
} else {
m.addEventListener('google-map-ready', cb);
}
};

suite('google-map', function() {

// TODO: test setting an invalid latitude/longitude value. See if throws.
Expand All @@ -29,11 +37,11 @@
test.skip('invalid lat/lng');

test('noAutoTilt', function() {
map.addEventListener('google-map-ready', function(e) {
whenReady(map, function(e) {
// When noAutoTilt is set, tilt is left at default (45).
assert.equal(map.map.getTilt(), 45);
});
map3.addEventListener('google-map-ready', function(e) {
whenReady(map3, function(e) {
// When noAutoTilt is set, tilt is set to 0.
assert.equal(map3.map.getTilt(), 0);
});
Expand Down Expand Up @@ -72,7 +80,7 @@
});

test('change properties', function(done) {
map3.addEventListener('google-map-ready', function(e) {
whenReady(map3, function(e) {
assert.isTrue(map3.fitToMarkers);
assert.equal(map3.markers.length, 0);
assert.equal(map3.zoom, map3.map.getZoom());
Expand Down
10 changes: 9 additions & 1 deletion test/google-map-update-pos.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@

<script>
var map = document.querySelector('#map');
var whenReady = function(cb) {
if (map.map) {
cb();
} else {
map.addEventListener('google-map-ready', cb);
}
};


suite('markers', function() {

test('update lat/lng', function(done) {
map.addEventListener('google-map-ready', function(e) {
whenReady(function(e) {
assert.equal(map.latitude, 37.555);
assert.equal(map.longitude, -122.555);

Expand Down
12 changes: 9 additions & 3 deletions test/marker-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
<script>
var map = document.querySelector('#map1');

var whenReady = function(cb) {
if (map.map) {
cb();
} else {
map.addEventListener('google-map-ready', cb);
}
};

suite('markers', function() {
test('labeled marker should have a label', function() {
var markerEl = document.querySelector('#labeled-marker');
Expand All @@ -42,8 +50,6 @@

test('defaults', function() {
var markerEl = Polymer.dom(map).querySelector('google-map-marker');
assert.isUndefined(markerEl.marker);
assert.isUndefined(markerEl.map);
assert.isNull(markerEl.icon);
assert.isNull(markerEl.info);
assert.equal(markerEl.zIndex, 0);
Expand All @@ -55,7 +61,7 @@
});

test('update properties', function(done) {
map.addEventListener('google-map-ready', function(e) {
whenReady(function(e) {
var markerEl = Polymer.dom(map).querySelector('google-map-marker');
markerEl.latitude = 37.77493;
markerEl.longitude = -122.41942;
Expand Down
52 changes: 31 additions & 21 deletions test/markers-add-remove.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,42 @@
<script>
var map = document.querySelector('#map1');

suite(`markers${Polymer.Settings.useShadow ? ' (shadow dom)' : ' (shady dom)'}`, function() {

test('markers are defined, added, removed', function(done) {
map.addEventListener('google-map-ready', function(e) {

// Check if marker children were setup and can be added/removed.
assert.equal(map.markers.length, 2);

var marker = map.markers[0];
Polymer.dom((Polymer.dom(marker).parentNode)).removeChild(marker);
Polymer.dom.flush();
async.nextTick(function() { // needed because map.updateMarkers has mutationObserver
assert.equal(map.markers.length, 1);
assert.isNull(
marker.marker.map, 'removed marker is still visible on map');
Polymer.dom(map).appendChild(marker);
var whenReady = function(cb) {
if (map.map) {
cb();
} else {
map.addEventListener('google-map-ready', cb);
}
};

addEventListener('WebComponentsReady', function() {
suite(`markers${Polymer.Settings.useShadow ? ' (shadow dom)' : ' (shady dom)'}`, function() {

test('markers are defined, added, removed', function(done) {
whenReady(function(e) {

// Check if marker children were setup and can be added/removed.
assert.equal(map.markers.length, 2);

var marker = map.markers[0];
Polymer.dom((Polymer.dom(marker).parentNode)).removeChild(marker);
Polymer.dom.flush();
async.nextTick(function() {
assert.isNotNull(
marker.marker.map, 're-added marker is not visible.');
done();
async.nextTick(function() { // needed because map.updateMarkers has mutationObserver
assert.equal(map.markers.length, 1);
assert.isNull(
marker.marker.map, 'removed marker is still visible on map');
Polymer.dom(map).appendChild(marker);
Polymer.dom.flush();
async.nextTick(function() {
assert.isNotNull(
marker.marker.map, 're-added marker is not visible.');
done();
});
});
});
});
});

});
});

</script>
Expand Down
70 changes: 35 additions & 35 deletions test/poly-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,25 @@
var point3 = document.querySelector('#point3');
var point4 = document.querySelector('#point4');

test('before map is ready', function() {
assert.isUndefined(poly.map);
assert.isUndefined(poly.path);
assert.isUndefined(poly.poly);
var whenReady = function(cb) {
if (map.map) {
cb();
} else {
map.addEventListener('google-map-ready', cb);
}
};

test('defaults', function() {
assert.isFalse(poly.editing);
assert.isNull(poly.offsetParent, 'google-map-poly should be display: none');
});

test('after poly is initialized', function(done) {
map.addEventListener('google-map-ready', function(e) {
assert.isNotNull(poly.map);
//done();
});

var listener;
poly.addEventListener('google-map-poly-path-built', listener = function(e) {
poly.removeEventListener('google-map-poly-path-built', listener);

assert.isNotNull(poly.path);
assert.isNotNull(poly.poly);
whenReady(function(e) {
flush(function() {
assert.isNotNull(poly.map);
assert.isNotNull(poly.path);
assert.isNotNull(poly.poly);
assert.equal(poly.path.getLength(), 4);
assert.equal(poly.path.getAt(0).lat(), point1.latitude);
assert.equal(poly.path.getAt(0).lng(), point1.longitude);
Expand Down Expand Up @@ -82,28 +80,30 @@
});

test('when styling is changed', function(done) {
poly.clickable = true;
poly.draggable = true;
poly.editable = true;
poly.geodesic = true;
poly.hidden = true;
poly.strokeColor = 'white';
poly.strokeOpacity = .5;
poly.strokeWeight = 2;
poly.zIndex = 1;
whenReady(function() {
poly.clickable = true;
poly.draggable = true;
poly.editable = true;
poly.geodesic = true;
poly.hidden = true;
poly.strokeColor = 'white';
poly.strokeOpacity = .5;
poly.strokeWeight = 2;
poly.zIndex = 1;

flush(function() {
assert.isTrue(poly.poly.get('clickable'));
assert.isTrue(poly.poly.getDraggable());
assert.isTrue(poly.poly.getEditable());
assert.isTrue(poly.poly.get('geodesic'));
assert.equal(poly.poly.get('strokeColor'), 'white');
assert.equal(poly.poly.get('strokeOpacity'), .5);
assert.equal(poly.poly.get('strokeWeight'), 2);
assert.isFalse(poly.poly.getVisible());
assert.equal(poly.poly.get('zIndex'), 1);
flush(function() {
assert.isTrue(poly.poly.get('clickable'));
assert.isTrue(poly.poly.getDraggable());
assert.isTrue(poly.poly.getEditable());
assert.isTrue(poly.poly.get('geodesic'));
assert.equal(poly.poly.get('strokeColor'), 'white');
assert.equal(poly.poly.get('strokeOpacity'), .5);
assert.equal(poly.poly.get('strokeWeight'), 2);
assert.isFalse(poly.poly.getVisible());
assert.equal(poly.poly.get('zIndex'), 1);

done();
done();
});
});
});

Expand Down
9 changes: 8 additions & 1 deletion test/poly-custom-properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@
var map = document.querySelector('#map');
var poly = document.querySelector('#poly');

var whenReady = function(cb) {
if (map.map) {
cb();
} else {
map.addEventListener('google-map-ready', cb);
}
};

test('after poly is initialized', function(done) {
map.addEventListener('google-map-ready', function(e) {
whenReady(function(e) {
assert.isNotNull(poly.map);
//done();
});
Expand Down