File size: 1,333 Bytes
3206347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { describe, it, expect, beforeEach } from 'vitest';
import { createStep } from '../../test/factories/step';
import { createExecutionStep } from '../../test/factories/execution-step';
import stepSerializer from './step';
import executionStepSerializer from './execution-step';

describe('stepSerializer', () => {
  let step;

  beforeEach(async () => {
    step = await createStep();
  });

  it('should return step data', async () => {
    const expectedPayload = {
      id: step.id,
      type: step.type,
      key: step.key,
      appKey: step.appKey,
      iconUrl: step.iconUrl,
      webhookUrl: step.webhookUrl,
      status: step.status,
      position: step.position,
      parameters: step.parameters,
    };

    expect(stepSerializer(step)).toEqual(expectedPayload);
  });

  it('should return step data with the execution steps', async () => {
    const executionStepOne = await createExecutionStep({ stepId: step.id });
    const executionStepTwo = await createExecutionStep({ stepId: step.id });

    step.executionSteps = [executionStepOne, executionStepTwo];

    const expectedPayload = {
      executionSteps: [
        executionStepSerializer(executionStepOne),
        executionStepSerializer(executionStepTwo),
      ],
    };

    expect(stepSerializer(step)).toMatchObject(expectedPayload);
  });
});