From 7b594ca9061e94c7ba22ffdd9facf44f8dd33ee0 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Mon, 13 Dec 2021 13:34:28 -0500 Subject: [PATCH] chore: allow bexpr filtering of scope mocks --- addons/api/mirage/config.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index da0632da8..3ec44c437 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -26,16 +26,18 @@ export default function () { this.get( '/scopes', - ({ scopes }, { queryParams: { scope_id, recursive } }) => { + ({ scopes }, { queryParams: { scope_id, recursive, filter } }) => { + let resultSet; // Default parent scope is global if (!scope_id) scope_id = 'global'; if (recursive && scope_id === 'global') { - return scopes.all(); + resultSet = scopes.all(); } else { - return scopes.where((scope) => { + resultSet = scopes.where((scope) => { return scope.scope ? scope.scope.id === scope_id : false; }); } + return resultSet.filter(makeBooleanFilter(filter)); } ); this.post('/scopes', function ({ scopes }) {