From 3fceb787c148cf1788b0543e37ccb3a0672c93de Mon Sep 17 00:00:00 2001 From: Derek Wickern Date: Wed, 3 Nov 2021 17:21:37 -0700 Subject: [PATCH] use partial match on the request body --- addon/mocks/mock-request.js | 2 +- tests/unit/mocks/mock-any-test.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addon/mocks/mock-request.js b/addon/mocks/mock-request.js index bc4159cf..f1be0462 100644 --- a/addon/mocks/mock-request.js +++ b/addon/mocks/mock-request.js @@ -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) { diff --git a/tests/unit/mocks/mock-any-test.js b/tests/unit/mocks/mock-any-test.js index 84fae2d8..e2035895 100644 --- a/tests/unit/mocks/mock-any-test.js +++ b/tests/unit/mocks/mock-any-test.js @@ -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) {