From 4f7a3164f07923e6fddf9b56a8f155d24c2a27c1 Mon Sep 17 00:00:00 2001 From: Narek Hovhannisyan Date: Wed, 18 Dec 2024 01:45:55 +0400 Subject: [PATCH] test(lib): add additional case to cover already regrouped tree --- src/__tests__/if-run/lib/compute.test.ts | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/__tests__/if-run/lib/compute.test.ts b/src/__tests__/if-run/lib/compute.test.ts index 5718ba88..c0261ab2 100644 --- a/src/__tests__/if-run/lib/compute.test.ts +++ b/src/__tests__/if-run/lib/compute.test.ts @@ -187,6 +187,32 @@ describe('lib/compute: ', () => { expect(response.children.mockChild.children).toEqual(expectedResponse); }); + it('skips regrouping on already regrouped data.', async () => { + const {compute} = require('../../../if-run/lib/compute'); + const expectedResponse = { + 'uk-west': { + inputs: [{region: 'uk-west', timestamp: 'mock-timestamp-1'}], + }, + 'uk-east': { + inputs: [ + {region: 'uk-east', timestamp: 'mock-timestamp-2'}, + {region: 'uk-east', timestamp: 'mock-timestamp-3'}, + ], + }, + }; + const tree = { + children: { + mockChild: { + pipeline: {regroup: ['region']}, + children: expectedResponse, + }, + }, + }; + const response = await compute(tree, paramsExecute); + + expect(response.children.mockChild.children).toEqual(expectedResponse); + }); + it('computes simple tree with regroup, grouping inputs and outputs.', async () => { const {compute} = require('../../../if-run/lib/compute'); const tree = {