Browse Source

Fix unit tests failure caused my fetch-mock update

In some unit tests mockOptions.name was used instead of
mockOptions.matcher, and it was always undefined - this stopped
working with fetch-mock 5.5.0. This commit replaces
mockOptions.name with mockOptions.matcher where it is needed.

Change-Id: I367e1d957ce206c20c6b9d15c9f5ff1a2b285e33
Vitaly Kramskikh 2 years ago
parent
commit
08aa4981f1
3 changed files with 14 additions and 14 deletions
  1. 2
    2
      test/unit/glanceTest.js
  2. 6
    6
      test/unit/keystoneTest.js
  3. 6
    6
      test/unit/util/abstractServiceTest.js

+ 2
- 2
test/unit/glanceTest.js View File

@@ -91,11 +91,11 @@ describe('Glance', () => {
91 91
       glance
92 92
         .imageList(token)
93 93
         .then(() => {
94
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
94
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
95 95
           return glance.imageList(token);
96 96
         })
97 97
         .then(() => {
98
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
98
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
99 99
           done();
100 100
         })
101 101
         .catch((error) => done.fail(error));

+ 6
- 6
test/unit/keystoneTest.js View File

@@ -92,12 +92,12 @@ describe('Keystone', () => {
92 92
         .tokenIssue()
93 93
         .then((token) => {
94 94
           expect(token).toEqual('test_token'); // From mock data
95
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
95
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
96 96
           return keystone.tokenIssue();
97 97
         })
98 98
         .then((token) => {
99 99
           expect(token).toEqual('test_token'); // From mock data
100
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
100
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
101 101
           done();
102 102
         })
103 103
         .catch((error) => done.fail(error));
@@ -136,7 +136,7 @@ describe('Keystone', () => {
136 136
         .tokenRevoke(token)
137 137
         .then((response) => {
138 138
           expect(response.status).toEqual(204);
139
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
139
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
140 140
 
141 141
           // Yes, I realize that this should actually return an error since the token is no
142 142
           // longer valid, but we're testing for promise caching here, not valid http flow.
@@ -144,7 +144,7 @@ describe('Keystone', () => {
144 144
         })
145 145
         .then((response) => {
146 146
           expect(response.status).toEqual(204);
147
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
147
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
148 148
           done();
149 149
         })
150 150
         .catch((error) => done.fail(error));
@@ -181,11 +181,11 @@ describe('Keystone', () => {
181 181
       keystone
182 182
         .catalogList(token)
183 183
         .then(() => {
184
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
184
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
185 185
           return keystone.catalogList(token);
186 186
         })
187 187
         .then(() => {
188
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
188
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
189 189
           done();
190 190
         })
191 191
         .catch((error) => done.fail(error));

+ 6
- 6
test/unit/util/abstractServiceTest.js View File

@@ -112,11 +112,11 @@ describe('AbstractService', () => {
112 112
       service.versions()
113 113
         .then(() => {
114 114
           // Validate that the mock has only been invoked once
115
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
115
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
116 116
           return service.versions();
117 117
         })
118 118
         .then(() => {
119
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
119
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
120 120
           done();
121 121
         })
122 122
         .catch((error) => done.fail(error));
@@ -163,11 +163,11 @@ describe('AbstractService', () => {
163 163
       service.version()
164 164
         .then(() => {
165 165
           // Validate that the mock has only been invoked once
166
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
166
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
167 167
           return service.version();
168 168
         })
169 169
         .then(() => {
170
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
170
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
171 171
           done();
172 172
         })
173 173
         .catch((error) => done.fail(error));
@@ -229,11 +229,11 @@ describe('AbstractService', () => {
229 229
       service.serviceEndpoint()
230 230
         .then(() => {
231 231
           // Validate that the mock has only been invoked once
232
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
232
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
233 233
           return service.serviceEndpoint();
234 234
         })
235 235
         .then(() => {
236
-          expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
236
+          expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
237 237
           done();
238 238
         })
239 239
         .catch((error) => done.fail(error));

Loading…
Cancel
Save