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
This commit is contained in:
Vitaly Kramskikh 2016-10-04 16:29:51 +03:00
parent c5c58bcaad
commit 08aa4981f1
3 changed files with 14 additions and 14 deletions

View File

@ -91,11 +91,11 @@ describe('Glance', () => {
glance
.imageList(token)
.then(() => {
expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
return glance.imageList(token);
})
.then(() => {
expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
done();
})
.catch((error) => done.fail(error));

View File

@ -92,12 +92,12 @@ describe('Keystone', () => {
.tokenIssue()
.then((token) => {
expect(token).toEqual('test_token'); // From mock data
expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
return keystone.tokenIssue();
})
.then((token) => {
expect(token).toEqual('test_token'); // From mock data
expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
done();
})
.catch((error) => done.fail(error));
@ -136,7 +136,7 @@ describe('Keystone', () => {
.tokenRevoke(token)
.then((response) => {
expect(response.status).toEqual(204);
expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
// Yes, I realize that this should actually return an error since the token is no
// longer valid, but we're testing for promise caching here, not valid http flow.
@ -144,7 +144,7 @@ describe('Keystone', () => {
})
.then((response) => {
expect(response.status).toEqual(204);
expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
done();
})
.catch((error) => done.fail(error));
@ -181,11 +181,11 @@ describe('Keystone', () => {
keystone
.catalogList(token)
.then(() => {
expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
return keystone.catalogList(token);
})
.then(() => {
expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
done();
})
.catch((error) => done.fail(error));

View File

@ -112,11 +112,11 @@ describe('AbstractService', () => {
service.versions()
.then(() => {
// Validate that the mock has only been invoked once
expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
return service.versions();
})
.then(() => {
expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
done();
})
.catch((error) => done.fail(error));
@ -163,11 +163,11 @@ describe('AbstractService', () => {
service.version()
.then(() => {
// Validate that the mock has only been invoked once
expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
return service.version();
})
.then(() => {
expect(fetchMock.calls(mockOptions.name).length).toEqual(2);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(2);
done();
})
.catch((error) => done.fail(error));
@ -229,11 +229,11 @@ describe('AbstractService', () => {
service.serviceEndpoint()
.then(() => {
// Validate that the mock has only been invoked once
expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
return service.serviceEndpoint();
})
.then(() => {
expect(fetchMock.calls(mockOptions.name).length).toEqual(1);
expect(fetchMock.calls(mockOptions.matcher).length).toEqual(1);
done();
})
.catch((error) => done.fail(error));