Skip to content

Commit

Permalink
use partial match on the request body
Browse files Browse the repository at this point in the history
  • Loading branch information
dwickern committed Nov 4, 2021
1 parent 326261d commit 3fceb78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addon/mocks/mock-request.js
Expand Up @@ -161,7 +161,7 @@ export default class {
if (isEmptyObject(matchParams)) {
return true;
}
return isEquivalent(toParams(requestBody), toParams(matchParams));
return isPartOf(toParams(requestBody), toParams(matchParams));
}

extraRequestMatches(request) {
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/mocks/mock-any-test.js
Expand Up @@ -196,7 +196,10 @@ module('MockAny', function (hooks) {
const theMock = mock({ url, type: method }).match(whatsUp);

await fetchJSON({ url, params: whatsUp, method });
assert.equal(theMock.timesCalled, 1, 'the mock was called');
assert.equal(theMock.timesCalled, 1, 'exact match');

await fetchJSON({ url, params: { whats: 'up', foo: 'bar' }, method });
assert.equal(theMock.timesCalled, 2, 'partial match');
});

test('match a function', async function (assert) {
Expand Down

0 comments on commit 3fceb78

Please sign in to comment.