Skip to content

Commit

Permalink
Update dependencies and fix tests for new version of jasmine.
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanfprice committed Jan 4, 2017
1 parent 20a5e2e commit 1d55ea6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 62 deletions.
41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@
},
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.4",
"phantomjs": "~1.9.1-0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-jshint": "~0.6.2",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-connect": "~0.6.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-karma": "~0.8.2",
"jshint": "~2.5.0",
"karma-script-launcher": "~0.1.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.4",
"karma-chrome-launcher": "~0.1.3",
"karma-firefox-launcher": "~0.1.3",
"karma-jasmine": "~0.1.5",
"karma-requirejs": "~0.2.0",
"karma-coffee-preprocessor": "~0.2.1",
"karma": "~0.12.5",
"karma-coverage": "~0.2.1",
"grunt": "~1.0.1",
"grunt-contrib-clean": "~1.0.0",
"grunt-contrib-concat": "~1.0.1",
"grunt-contrib-connect": "~1.0.2",
"grunt-contrib-copy": "~1.0.0",
"grunt-contrib-jshint": "~1.1.0",
"grunt-contrib-uglify": "~2.0.0",
"grunt-karma": "~2.0.0",
"jasmine-core": "2.5.2",
"jshint": "~2.9.4",
"karma": "~1.3.0",
"karma-chrome-launcher": "~2.0.0",
"karma-coffee-preprocessor": "~1.0.1",
"karma-coverage": "~1.1.1",
"karma-firefox-launcher": "~1.0.0",
"karma-html2js-preprocessor": "~1.1.0",
"karma-jasmine": "~1.1.0",
"karma-phantomjs-launcher": "~1.0.2",
"karma-requirejs": "~1.1.0",
"karma-script-launcher": "~1.0.0",
"phantomjs-prebuilt": "~2.1.7",
"grunt-ngdocs": "~0.2.1"
}
}
21 changes: 5 additions & 16 deletions test/unit/directives/gmMapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('gmMap', function() {
// get MapController
mapCtrl = elm.controller('gmMap');

spyOn(mapCtrl, 'mapTrigger').andCallThrough();
spyOn(mapCtrl, 'mapTrigger').and.callThrough();

var center, zoom, bounds;
Object.defineProperties(mapCtrl, {
Expand Down Expand Up @@ -238,29 +238,18 @@ describe('gmMap', function() {
expect(mapCtrl.mapTrigger).not.toHaveBeenCalled();
});

it('fires idle event when map loaded', inject(function($compile, $timeout) {
it('fires idle event when map loaded', function(done) {
// this test is slow because we have to wait for google maps to load--eckh
var called = false;

runs(function() {
var t = inject(function($compile) {
elm = angular.element('<gm-map gm-map-id="mapId" gm-center="pCenter" gm-zoom="pZoom" gm-bounds="pBounds"></gm-map>');
var newScope = scope.$new();
newScope.mapId = scope.mapId + 'diff';
newScope.$on('gmMapIdle', function(event, mapId) {
if (mapId === newScope.mapId) {
called = true;
done();
}
});
$compile(elm)(newScope);
});

waitsFor(function() {
return called;
}, 'Should fire idle event', 750);

runs(function() {
expect(called).toBeTruthy();
});
}));

});
});
49 changes: 24 additions & 25 deletions test/unit/directives/gmMarkersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ describe('gmMarkers', function() {
$compile(elm)(scope);

mapCtrl = elm.controller('gmMap');
spyOn(mapCtrl, 'addElement').andCallThrough();
spyOn(mapCtrl, 'updateElement').andCallThrough();
spyOn(mapCtrl, 'removeElement').andCallThrough();
spyOn(mapCtrl, 'trigger').andCallThrough();
spyOn(mapCtrl, 'addListener').andCallThrough();
spyOn(mapCtrl, 'addElement').and.callThrough();
spyOn(mapCtrl, 'updateElement').and.callThrough();
spyOn(mapCtrl, 'removeElement').and.callThrough();
spyOn(mapCtrl, 'trigger').and.callThrough();
spyOn(mapCtrl, 'addListener').and.callThrough();

markersScopeId = elm.find('gm-markers').isolateScope().$id;

Expand Down Expand Up @@ -134,8 +134,8 @@ describe('gmMarkers', function() {
scope.people.push({name: 'new' + i, id: (i+10), location: {lat: i, lng: i}});
}
scope.$digest();
expect(mapCtrl.removeElement.calls.length).toEqual(length);
expect(mapCtrl.addElement.calls.length).toEqual(length * 2);
expect(mapCtrl.removeElement.calls.count()).toEqual(length);
expect(mapCtrl.addElement.calls.count()).toEqual(length * 2);
});


Expand All @@ -151,7 +151,7 @@ describe('gmMarkers', function() {
var origLength = scope.people.length;
scope.people.push({name: '0', id: 0, location: {lat: 2, lng: 3}});
scope.$digest();
expect(mapCtrl.addElement.callCount).toEqual(origLength);
expect(mapCtrl.addElement.calls.count()).toEqual(origLength);
});


Expand All @@ -170,7 +170,7 @@ describe('gmMarkers', function() {
var origLength = scope.people.length;
scope.people.push(null);
scope.$digest();
expect(mapCtrl.addElement.callCount).toEqual(origLength);
expect(mapCtrl.addElement.calls.count()).toEqual(origLength);
});

});
Expand All @@ -195,8 +195,8 @@ describe('gmMarkers', function() {

scope.$digest();
$timeout.flush();
var marker = mapCtrl.trigger.mostRecentCall.args[0];
var event = mapCtrl.trigger.mostRecentCall.args[1];
var marker = mapCtrl.trigger.calls.mostRecent()['args'][0];
var event = mapCtrl.trigger.calls.mostRecent()['args'][1];
expect(latLngToObj(marker.getPosition())).toEqual(position);
expect(event).toEqual('click');
});
Expand All @@ -214,8 +214,8 @@ describe('gmMarkers', function() {
}]
scope.$digest();
$timeout.flush();
var marker0 = mapCtrl.trigger.calls[0].args[0];
var marker1 = mapCtrl.trigger.calls[1].args[0];
var marker0 = mapCtrl.trigger.calls.argsFor(0)[0];
var marker1 = mapCtrl.trigger.calls.argsFor(1)[0];
expect(latLngToObj(marker0.getPosition())).toEqual(position0);
expect(latLngToObj(marker1.getPosition())).toEqual(position1);
});
Expand All @@ -236,8 +236,8 @@ describe('gmMarkers', function() {
]
scope.$digest();
$timeout.flush();
var event0 = mapCtrl.trigger.calls[0].args[1];
var event1 = mapCtrl.trigger.calls[1].args[1];
var event0 = mapCtrl.trigger.calls.argsFor(0)[1];
var event1 = mapCtrl.trigger.calls.argsFor(1)[1];
expect(event0).toEqual('event0');
expect(event1).toEqual('event1');
});
Expand All @@ -250,20 +250,19 @@ describe('gmMarkers', function() {
});


it('calls event handlers when event fired', function() {
var person = scope.people[0];
var marker = mapCtrl.getElement('marker', markersScopeId, person.name);
var handled = false;
runs(function() {
google.maps.event.addListener(marker, 'mouseover', function() {handled = true;});
describe('calls event handlers when event fired', function() {
beforeEach(function(done) {
var person = scope.people[0];
var marker = mapCtrl.getElement('marker', markersScopeId, person.name);
google.maps.event.addListener(marker, 'mouseover', done);
google.maps.event.trigger(marker, 'mouseover');
});
waitsFor(function() {
return handled;
}, 'no mouseover', 500);
runs(function() {

it('', function() {
scope.$digest();
$timeout.flush();

var person = scope.people[0];
expect(scope.mouseovered.person).toEqual(person);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/services/angulargmContainerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('angulargmContainer', function() {

beforeEach(inject(function(angulargmContainer) {
cntr = angulargmContainer;
mapSpy = spyOn(google.maps, 'Map').andCallFake(function() {
mapSpy = spyOn(google.maps, 'Map').and.callFake(function() {
});
}));

Expand Down

0 comments on commit 1d55ea6

Please sign in to comment.