blob: 6469cca462e65bebf46d33914684335ab56a7224 [file] [log] [blame]
Matteo Scandoloa4a47112016-12-16 10:06:13 -08001import * as angular from 'angular';
2import 'angular-mocks';
3import 'angular-resource';
4import 'angular-cookies';
5import {xosDataSources} from '../index';
6import {AppConfig} from '../../config/app.config';
7import {IModeldefsService} from './modeldefs.rest';
8
9let service: IModeldefsService;
10let httpBackend: ng.IHttpBackendService;
11let $scope;
12
13describe('The ModelDefs service', () => {
14
15 beforeEach(angular.mock.module(xosDataSources));
16
17 beforeEach(() => {
18 angular.mock.module(xosDataSources);
19 });
20
21
22 beforeEach(angular.mock.inject((
23 ModelDefs: IModeldefsService,
24 $httpBackend: ng.IHttpBackendService,
25 _$resource_: ng.resource.IResourceService,
26 _$rootScope_: ng.IRootScopeService
27 ) => {
28 service = ModelDefs;
29 httpBackend = $httpBackend;
30 $scope = _$rootScope_;
31 }));
32
33 it('should have a get method', (done) => {
34 httpBackend.expectGET(`${AppConfig.apiEndpoint}/utility/modeldefs/`)
35 .respond([
36 {name: 'ok'}
37 ]);
38 service.get()
39 .then((res) => {
40 expect(res[0].name).toEqual('ok');
41 done();
42 })
43 .catch(e => {
44 done(e);
45 });
46 $scope.$apply();
47 httpBackend.flush();
48 });
49});