Service
Service dashboardApp.factory('ExecutiveService', ['$http', function ($http) {
var _getDashboardData = function () {
return $http.get('/app/data/dashboard.txt');
};
return {
getDashboardData: _getDashboardData
}
} ]);
this is the service used for getting a json file into action
Spec 'use strict';
describe('Testing ExecutiveServices', function() {
var service, httpBackend, data;
beforeEach(module('do.dashboard'));
beforeEach(inject(function(ExecutiveService, _$httpBackend_) {
service = ExecutiveService;
httpBackend = _$httpBackend_;
}));
it ('should be loaded', function() {
expect(service).toBeDefined();
});
it ('should return data when calling _getDashboardData', function() {
httpBackend.expectGET('/app/data/dashboard.txt');
service._getDashboardData().then(function(result) {
data = result;
});
httpBackend.flush();
expect(data).toBe('some data');
});
afterEach(function() {
// make sure all requests where handled as expected.
httpBackend.verifyNoOutstandingRequest();
httpBackend.verifyNoOutstandingExpectation();
});
});
the error i am getting is this Chrome 40.0.2214 (Windows 7) Testing ExecutiveServices should return data when calling _getDashboardData FAILED
Aucun commentaire:
Enregistrer un commentaire