Skip to content

Commit

Permalink
Create secureMessaging.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 4, 2024
1 parent c825505 commit 0611485
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/secureMessaging.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// secureMessaging.test.js

const SecureMessaging = require('./secureMessaging'); // Assuming you have a SecureMessaging module

describe('Secure Messaging Features', () => {
let messaging;

beforeEach(() => {
messaging = new SecureMessaging();
});

test('should send a message securely', () => {
const result = messaging.sendMessage('user1', 'user2', 'Hello, World!');
expect(result).toBe(true);
});

test('should receive a message securely', () => {
messaging.sendMessage('user1', 'user2', 'Hello, World!');
const messages = messaging.receiveMessages('user2');
expect(messages).toContainEqual(expect.objectContaining({
from: 'user1',
content: 'Hello, World!',
}));
});

test('should encrypt messages before sending', () => {
const message = 'Secret Message';
const encryptedMessage = messaging.encryptMessage(message);
expect(encryptedMessage).not.toBe(message);
});

test('should decrypt messages after receiving', () => {
const message = 'Secret Message';
const encryptedMessage = messaging.encryptMessage(message);
const decryptedMessage = messaging.decryptMessage(encryptedMessage);
expect(decryptedMessage).toBe(message);
});
});

0 comments on commit 0611485

Please sign in to comment.