Skip to content

Commit

Permalink
Testing: Partially convert Service tests to ngDescribe style;
Browse files Browse the repository at this point in the history
  • Loading branch information
khfayzullaev committed Sep 17, 2015
1 parent cb54fc0 commit d94bfec
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
!www/js/filters-spec.js
!www/js/directives.js
!www/js/services.js
!www/js/services-spec.js
!www/lib/angular-cache/*
!www/lib/angular-leaflet/*
!www/lib/leaflet/*
Expand Down
7 changes: 6 additions & 1 deletion www/SpecRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
});
});

/* Converted to ngDescribe */
/*
describe('AtStopService Tests (note: server/data dependent)', function () {
var ctrl, scope;
beforeEach(module('atstop'));
Expand Down Expand Up @@ -128,8 +130,10 @@
});
});
*/


/* Converted to ngDescribe */
/*
describe('Geolocation Tests', function () {
var ctrl, scope;
beforeEach(module('atstop'));
Expand All @@ -146,6 +150,7 @@
})
});
*/

/* Converted to ngDescribe */
/*
Expand Down
41 changes: 41 additions & 0 deletions www/js/services-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ngDescribe({
name: 'Service: Geolocation tests',
modules: 'atstop',
inject: 'GeolocationService',
tests: function(deps) {
it('should return nearby stops', function() {
var lat = 40.748433;
var lon = -73.985656;
deps.GeolocationService.getStops(lat, lon).then(function(results) {
expect(results.length).to.BeGreaterThan(0);
});
});
}
});

ngDescribe({
name: 'Service: At Stop Service tests (note: server/data dependent)',
modules: 'atstop',
inject: 'AtStopService',
tests: function(deps) {
it('should return results for a stop', function() {
var stop = 'MTA_400861';
deps.AtStopService.getBuses(stop).then(function(results) {
expect(Object.keys(data.arriving).length).toBeGreaterThan(1);
});
});

it('should return results for one route at a stop', function() {
var stop = 'MTA_400861';
var line = 'MTA NYCT_M7';
var params = {
'stop': stop,
'line': line
};
var data = {};
deps.AtStopService.getBuses(params).then(function(results) {
except(Object.keys(data.arriving).length).toBeEqualTo(1);
});
});
}
});

0 comments on commit d94bfec

Please sign in to comment.