feat: Introduce step serializer

This commit is contained in:
Faruk AYDIN
2024-02-25 23:01:55 +01:00
parent ed1c3cffc1
commit 7e35f544eb
2 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
const stepSerializer = (step) => {
return {
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,
};
};
export default stepSerializer;

View File

@@ -0,0 +1,27 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { createStep } from '../../test/factories/step';
import stepSerializer from './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);
});
});