Skip to content

Commit

Permalink
test(lib): update uni tests for compute
Browse files Browse the repository at this point in the history
  • Loading branch information
narekhovhannisyan committed Dec 17, 2024
1 parent fc6cc88 commit 91073dd
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/__tests__/if-run/lib/compute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ jest.mock('../../../common/util/logger', () => ({
},
}));

import * as explainer from '../../../if-run/lib/explain';

import {compute} from '../../../if-run/lib/compute';
import {ComputeParams} from '../../../if-run/types/compute';
import {pluginStorage} from '../../../if-run/util/plugin-storage';

describe('lib/compute: ', () => {
beforeEach(() => {
jest.resetModules();
});

/**
* Mock plugins.
*/
Expand Down Expand Up @@ -134,7 +135,12 @@ describe('lib/compute: ', () => {
const paramsExecuteWithAppend = {...paramsExecute, append: true};

describe('compute(): ', () => {
beforeEach(() => {
jest.resetModules();
});

it('computes simple tree with execute plugin.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand All @@ -156,6 +162,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with regroup on inputs only (no compute).', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand Down Expand Up @@ -185,6 +192,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with regroup, grouping inputs and outputs.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand Down Expand Up @@ -232,6 +240,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with defaults and execute plugin.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand Down Expand Up @@ -259,6 +268,7 @@ describe('lib/compute: ', () => {
});

it('computes nested tree with defaults and execute plugin.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild1: {
Expand Down Expand Up @@ -308,6 +318,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with no defaults and no inputs with execute plugin.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand All @@ -323,6 +334,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with defaults and no inputs with execute plugin.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand All @@ -343,6 +355,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with append, preserving existing outputs.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand Down Expand Up @@ -378,6 +391,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with append when outputs is null.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand All @@ -402,6 +416,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with regroup and append, with existing outputs preserved and regrouped without re-computing.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand Down Expand Up @@ -434,6 +449,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with regroup and append, with existing outputs preserved and without new outputs.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand All @@ -460,6 +476,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with regroup and no append, with existing outputs that are removed.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand Down Expand Up @@ -488,6 +505,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with observe plugin.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand All @@ -507,6 +525,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with observe plugin.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand All @@ -526,6 +545,7 @@ describe('lib/compute: ', () => {
});

it('observes simple tree with observe plugin.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand All @@ -545,6 +565,7 @@ describe('lib/compute: ', () => {
});

it('observes simple tree with config.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand All @@ -565,6 +586,7 @@ describe('lib/compute: ', () => {
});

it('warns when pipeline is null.', async () => {
const {compute} = require('../../../if-run/lib/compute');
process.env.LOGGER = 'invalid';
const tree = {
children: {
Expand All @@ -583,6 +605,7 @@ describe('lib/compute: ', () => {
});

it('warns when pipeline is an empty object.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand All @@ -598,6 +621,7 @@ describe('lib/compute: ', () => {
});

it('warns when config is provided in the tree.', async () => {
const {compute} = require('../../../if-run/lib/compute');
process.env.LOGGER = 'true';
const tree = {
children: {
Expand All @@ -624,6 +648,7 @@ describe('lib/compute: ', () => {
});

it('warns when config is provided in the tree and it is null.', async () => {
const {compute} = require('../../../if-run/lib/compute');
process.env.LOGGER = 'empty';
const tree = {
children: {
Expand All @@ -650,6 +675,8 @@ describe('lib/compute: ', () => {
});

it('observes simple tree with execute plugin and explain property.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const explainer = require('../../../if-run/lib/explain');
const tree = {
children: {
mockChild: {
Expand Down Expand Up @@ -678,6 +705,7 @@ describe('lib/compute: ', () => {
});

it('computes simple tree with execute plugin and explain property.', async () => {
const {compute} = require('../../../if-run/lib/compute');
const tree = {
children: {
mockChild: {
Expand Down

0 comments on commit 91073dd

Please sign in to comment.