1
1
/* eslint-env jasmine */
2
- /* global dump */
3
2
4
3
'use strict' ;
5
4
@@ -26,27 +25,45 @@ describe('count', function() {
26
25
} ) ;
27
26
28
27
29
- // it('should make call to correct url', function() {
30
- // var requestedUrl = 'https://foo/attask/api/task/count?name=some+task+name&name_Mod=cicontains';
31
- // $httpBackend.expectGET(requestedUrl)
32
- // .respond(200);
33
- // var query = {};
34
- // query['name'] = 'some task name';
35
- // query['name' + streamApi.Constants.MOD] = streamApi.Constants.Operators.CICONTAINS;
36
- // streamApi.count('task', query);
37
-
38
- // $httpBackend.flush();
39
- // });
28
+ it ( 'should make call to correct url' , function ( ) {
29
+ var requestedUrl = 'https://foo/attask/api-internal/task/count?name=some+task+name&name_Mod=cicontains' ;
30
+ var data = { count : 1 } ;
31
+ $httpBackend . whenGET ( requestedUrl )
32
+ . respond ( 200 ) ;
33
+ var query = { } ;
34
+ query [ 'name' ] = 'some task name' ;
35
+ query [ 'name' + streamApi . Constants . MOD ] = streamApi . Constants . Operators . CICONTAINS ;
36
+ streamApi . count ( 'task' , query ) ;
40
37
41
- it ( 'should extract correct count from returend data' , function ( done ) {
42
- var data = { count : 5 } ;
38
+ $httpBackend . flush ( ) ;
39
+ } ) ;
40
+
41
+
42
+ it ( 'should fail when response not correct' , function ( done ) {
43
+ var response = { aaa :3 } ;
44
+ var errorHander = jasmine . createSpy ( 'errorHandler' ) ;
43
45
$httpBackend . whenGET ( )
46
+ . respond ( 200 , response ) ;
47
+ streamApi . count ( 'task' , { } )
48
+ . catch ( errorHander )
49
+ . finally ( function ( ) {
50
+ expect ( errorHander ) . toHaveBeenCalled ( ) ;
51
+ done ( ) ;
52
+ } ) ;
53
+
54
+ $httpBackend . flush ( ) ;
55
+ } ) ;
56
+
57
+ it ( 'should extract correct count from returend data' , function ( done ) {
58
+ var data = { count : 5 } ;
59
+ $httpBackend . expectGET ( )
44
60
. respond ( 200 , data ) ;
45
61
streamApi . count ( 'task' , { } )
46
62
. then ( function ( count ) {
47
63
expect ( count ) . toBe ( data . count ) ;
48
64
done ( ) ;
49
65
} ) ;
66
+
50
67
$httpBackend . flush ( ) ;
51
68
} ) ;
52
69
} ) ;
0 commit comments