feat: Add connection serializer

This commit is contained in:
Faruk AYDIN
2024-03-13 13:11:54 +01:00
parent e3e598b208
commit 8f7f6dc19e
3 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { createConnection } from '../../test/factories/connection';
import connectionSerializer from './connection';
describe('connectionSerializer', () => {
let connection;
beforeEach(async () => {
connection = await createConnection();
});
it('should return connection data', async () => {
const expectedPayload = {
id: connection.id,
key: connection.key,
reconnectable: connection.reconnectable,
appAuthClientId: connection.appAuthClientId,
formattedData: {
screenName: connection.formattedData.screenName,
},
verified: connection.verified,
createdAt: connection.createdAt.getTime(),
updatedAt: connection.updatedAt.getTime(),
};
expect(connectionSerializer(connection)).toEqual(expectedPayload);
});
});