feat: Implement action serializer
This commit is contained in:
9
packages/backend/src/serializers/action.js
Normal file
9
packages/backend/src/serializers/action.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const actionSerializer = (action) => {
|
||||
return {
|
||||
name: action.name,
|
||||
key: action.key,
|
||||
description: action.description,
|
||||
};
|
||||
};
|
||||
|
||||
export default actionSerializer;
|
21
packages/backend/src/serializers/action.test.js
Normal file
21
packages/backend/src/serializers/action.test.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import App from '../models/app';
|
||||
import actionSerializer from './action';
|
||||
|
||||
describe('actionSerializer', () => {
|
||||
it('should return the action data', async () => {
|
||||
const actions = await App.findActionsByKey('github');
|
||||
const action = actions[0];
|
||||
|
||||
const expectedPayload = {
|
||||
description: action.description,
|
||||
key: action.key,
|
||||
name: action.name,
|
||||
pollInterval: action.pollInterval,
|
||||
showWebhookUrl: action.showWebhookUrl,
|
||||
type: action.type,
|
||||
};
|
||||
|
||||
expect(actionSerializer(action)).toEqual(expectedPayload);
|
||||
});
|
||||
});
|
@@ -8,6 +8,7 @@ import stepSerializer from './step.js';
|
||||
import appSerializer from './app.js';
|
||||
import authSerializer from './auth.js';
|
||||
import triggerSerializer from './trigger.js';
|
||||
import actionSerializer from './action.js';
|
||||
|
||||
const serializers = {
|
||||
User: userSerializer,
|
||||
@@ -20,6 +21,7 @@ const serializers = {
|
||||
App: appSerializer,
|
||||
Auth: authSerializer,
|
||||
Trigger: triggerSerializer,
|
||||
Action: actionSerializer,
|
||||
};
|
||||
|
||||
export default serializers;
|
||||
|
Reference in New Issue
Block a user