blob: 9dc4025ed010d9169cd4e05b4cf244eacbb5daeb [file] [log] [blame]
import * as angular from 'angular';
import 'angular-mocks';
import 'angular-resource';
import 'angular-cookies';
import {xosDataSources} from '../index';
import {IModeldefsService} from './modeldefs.rest';
let service: IModeldefsService;
let httpBackend: ng.IHttpBackendService;
let $scope;
const MockAppCfg = {
apiEndpoint: 'http://xos-test:3000/api',
websocketClient: 'http://xos-test:3000'
};
describe('The ModelDefs service', () => {
beforeEach(angular.mock.module(xosDataSources));
beforeEach(() => {
angular.module(xosDataSources)
.constant('AppConfig', MockAppCfg);
angular.mock.module(xosDataSources);
});
beforeEach(angular.mock.inject((
ModelDefs: IModeldefsService,
$httpBackend: ng.IHttpBackendService,
_$resource_: ng.resource.IResourceService,
_$rootScope_: ng.IRootScopeService
) => {
service = ModelDefs;
httpBackend = $httpBackend;
$scope = _$rootScope_;
}));
it('should have a get method', (done) => {
httpBackend.expectGET(`${MockAppCfg.apiEndpoint}/utility/modeldefs/`)
.respond([
{name: 'ok'}
]);
service.get()
.then((res) => {
expect(res[0].name).toEqual('ok');
done();
})
.catch(e => {
done(e);
});
$scope.$apply();
httpBackend.flush();
});
});