-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |