From acfd217142613b52efa02f807dfa9f3b9804072e Mon Sep 17 00:00:00 2001 From: Mark David Avery Date: Fri, 6 May 2022 08:26:45 -0700 Subject: [PATCH] spec: added additional tests to account for potential lookups of keys under values Signed-off-by: Mark David Avery --- .../parseEntityTransformParams.test.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-backend/src/service/request/parseEntityTransformParams.test.ts b/plugins/catalog-backend/src/service/request/parseEntityTransformParams.test.ts index 65f85639e1..ae1c8855ea 100644 --- a/plugins/catalog-backend/src/service/request/parseEntityTransformParams.test.ts +++ b/plugins/catalog-backend/src/service/request/parseEntityTransformParams.test.ts @@ -100,7 +100,6 @@ describe('parseEntityTransformParams', () => { 'subite.with/dot': 'fd2.sub.dot', }, 'third-field-with.dot-again': 'fd3', - type: 't', }; expect( @@ -129,4 +128,23 @@ describe('parseEntityTransformParams', () => { }, }); }); + + it('does not return a sub key if an incorrect longer key is requested', () => { + entity.spec = { + ...entity.spec, + 'field-with.dot': 'fd1', + plain: true, + numLike: 4, + arrayLike: [4, 5], + }; + + expect( + parseEntityTransformParams({ + fields: + 'kind,spec.field-withdot.other.item,kind.other.other,spec.plain.other,spec.numLike.other,spec.arrayLike.other', + })!(entity), + ).toEqual({ + kind: 'k', + }); + }); });