@@ -45,42 +45,48 @@ describe('Service: Hoverfly', () => {
45
45
46
46
} ) ;
47
47
48
- it ( 'getVersion should dispatch an update action' , ( ) => {
48
+ it ( 'getHoverflyInfo should dispatch an update action' , ( ) => {
49
49
50
- service . getVersion ( ) ;
50
+ const hoverflyInfo = {
51
+ destination : 'hoverfly.io' ,
52
+ mode : 'simulate' ,
53
+ usage : {
54
+ counters : {
55
+ capture : 0 ,
56
+ modify : 0 ,
57
+ simulate : 0 ,
58
+ spy : 0 ,
59
+ synthesize : 0
60
+ }
61
+ } ,
62
+ version : 'v0.15.0' ,
63
+ } ;
64
+
65
+ service . getHoverflyInfo ( ) ;
51
66
lastConnection . mockRespond ( new Response ( new ResponseOptions ( {
52
- body : { version : 'v0.11.4' } ,
67
+ body : hoverflyInfo ,
53
68
status : 200
54
69
} ) ) ) ;
55
70
56
71
expect ( lastConnection ) . toBeDefined ( ) ;
57
- expect ( lastConnection . request . url ) . toBe ( '/api/v2/hoverfly/version ' ) ;
72
+ expect ( lastConnection . request . url ) . toBe ( '/api/v2/hoverfly' ) ;
58
73
expect ( lastConnection . request . method ) . toBe ( RequestMethod . Get ) ;
59
74
60
75
expect ( ngRedux . dispatch ) . toHaveBeenCalledWith ( {
61
76
type : HOVERFLY_ACTIONS . UPDATE ,
62
- payload : { version : 'v0.11.4' }
77
+ payload : hoverflyInfo
63
78
} ) ;
64
79
65
80
} ) ;
66
81
67
- it ( 'getMode should dispatch an update action' , ( ) => {
82
+ it ( 'getHoverflyInfo failed should dispatch an error notification action' , ( ) => {
68
83
69
- service . getMode ( ) ;
70
- lastConnection . mockRespond ( new Response ( new ResponseOptions ( {
71
- body : { mode : 'capture' } ,
72
- status : 200
73
- } ) ) ) ;
84
+ service . getHoverflyInfo ( ) ;
85
+ lastConnection . mockError ( mockErrorResponse ( 0 ) ) ;
74
86
75
87
expect ( lastConnection ) . toBeDefined ( ) ;
76
- expect ( lastConnection . request . url ) . toBe ( '/api/v2/hoverfly/mode' ) ;
77
- expect ( lastConnection . request . method ) . toBe ( RequestMethod . Get ) ;
78
-
79
- expect ( ngRedux . dispatch ) . toHaveBeenCalledWith ( {
80
- type : HOVERFLY_ACTIONS . UPDATE ,
81
- payload : { mode : 'capture' }
82
- } ) ;
83
88
89
+ expect ( notifyService . sendError ) . toHaveBeenCalledWith ( API_ERRORS . SERVICE_UNAVAILABLE ) ;
84
90
} ) ;
85
91
86
92
it ( 'setMode should send hoverfly mode' , ( ) => {
@@ -103,34 +109,6 @@ describe('Service: Hoverfly', () => {
103
109
104
110
} ) ;
105
111
106
- it ( 'getDestination should dispatch an update action' , ( ) => {
107
-
108
- service . getDestination ( ) ;
109
- lastConnection . mockRespond ( new Response ( new ResponseOptions ( {
110
- body : { destination : 'destination.com' } ,
111
- status : 200
112
- } ) ) ) ;
113
-
114
- expect ( lastConnection ) . toBeDefined ( ) ;
115
- expect ( lastConnection . request . url ) . toBe ( '/api/v2/hoverfly/destination' ) ;
116
- expect ( lastConnection . request . method ) . toBe ( RequestMethod . Get ) ;
117
-
118
- expect ( ngRedux . dispatch ) . toHaveBeenCalledWith ( {
119
- type : HOVERFLY_ACTIONS . UPDATE ,
120
- payload : { destination : 'destination.com' }
121
- } ) ;
122
-
123
- } ) ;
124
-
125
- it ( 'getDestination failed should dispatch an error notification action' , ( ) => {
126
-
127
- service . getDestination ( ) ;
128
- lastConnection . mockError ( mockErrorResponse ( 0 ) ) ;
129
-
130
- expect ( lastConnection ) . toBeDefined ( ) ;
131
-
132
- expect ( notifyService . sendError ) . toHaveBeenCalledWith ( API_ERRORS . SERVICE_UNAVAILABLE ) ;
133
- } ) ;
134
112
135
113
it ( 'getMiddleware should dispatch an update action' , ( ) => {
136
114
@@ -174,33 +152,4 @@ describe('Service: Hoverfly', () => {
174
152
175
153
} ) ;
176
154
177
- it ( 'getUsage should dispatch an update action' , ( ) => {
178
-
179
- const usageData = {
180
- usage : {
181
- counters : {
182
- capture : 1 ,
183
- modify : 2 ,
184
- simulate : 3 ,
185
- synthesize : 4
186
- }
187
- }
188
- } ;
189
-
190
- service . getUsage ( ) ;
191
-
192
- lastConnection . mockRespond ( new Response ( new ResponseOptions ( {
193
- body : usageData ,
194
- status : 200
195
- } ) ) ) ;
196
- expect ( lastConnection ) . toBeDefined ( ) ;
197
- expect ( lastConnection . request . url ) . toBe ( '/api/v2/hoverfly/usage' ) ;
198
- expect ( lastConnection . request . method ) . toBe ( RequestMethod . Get ) ;
199
-
200
- expect ( ngRedux . dispatch ) . toHaveBeenCalledWith ( {
201
- type : HOVERFLY_ACTIONS . UPDATE ,
202
- payload : usageData
203
- } ) ;
204
- } ) ;
205
-
206
155
} ) ;
0 commit comments