Skip to content

Commit

Permalink
fix(apimock): normalize file paths for empty query params
Browse files Browse the repository at this point in the history
Empty/undefined query param values won’t be included in the mock data
file path. They were inconsistent anyway.

Fixes #48
  • Loading branch information
seriema committed Oct 18, 2015
1 parent 3a1ac50 commit 9252f71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/scripts/angular-apimock.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ angular.module('apiMock', [])
key +
(topLevel ? '' : ']'));
});
} else if (toSerialize === undefined || toSerialize === '') {
parts.push(encodeUriQuery(prefix));
} else {
parts.push(encodeUriQuery(prefix) + '=' + encodeUriQuery(serializeValue(toSerialize)));
}
Expand Down
4 changes: 2 additions & 2 deletions test/spec/services/angular-apimock.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ describe('Service: apiMock', function () {

it('should handle empty value', function () {
defaultRequest.url = '/api/pokemon?releaseDate';
defaultExpectPath = '/mock_data/pokemon/releasedate=.get.json';
defaultExpectPath = '/mock_data/pokemon/releasedate.get.json';

expectHttpSuccess();
});
Expand All @@ -740,7 +740,7 @@ describe('Service: apiMock', function () {
defaultRequest.params = {
'releaseDate': undefined
};
defaultExpectPath = '/mock_data/pokemon/releasedate=undefined.get.json';
defaultExpectPath = '/mock_data/pokemon/releasedate.get.json';

expectHttpSuccess();
});
Expand Down

0 comments on commit 9252f71

Please sign in to comment.