Skip to content

Commit 799bafe

Browse files
add encrypt and decrypt test specs
1 parent 6a194a1 commit 799bafe

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { expect } from 'chai';
2+
import { encryptDecrypt } from '../src/encryptDecrypt'; // Adjust the path as needed
3+
4+
describe('Lit Action encryptDecrypt test', function() {
5+
// Increase timeout for API calls
6+
this.timeout(60000); // Extended to 60 seconds
7+
8+
it('should encrypt and decrypt "Hello world" correctly', async () => {
9+
// Original message that should be recovered after decryption
10+
const originalMessage = 'Hello world';
11+
12+
try {
13+
const result = await encryptDecrypt();
14+
15+
// Basic success check
16+
expect(result.success, 'encryptDecrypt should execute successfully').to.be.true;
17+
18+
// If it failed, log the error for easier debugging
19+
if (!result.success) {
20+
console.error('Test failed with error:', result.error);
21+
expect.fail('Test failed but should have passed');
22+
}
23+
24+
// Verify that the response exists
25+
expect(result.response, 'Response should not be null').to.not.be.null;
26+
27+
// CRITICAL TEST: Verify the decrypted message matches the original input
28+
expect(result.response.response).to.equal(originalMessage,
29+
'Decrypted message should match the original "Hello world" message');
30+
31+
// Log success and response information for debugging
32+
console.log('Successfully verified encryption/decryption: Original message was properly recovered');
33+
console.log('Full response:', JSON.stringify(result.response, null, 2));
34+
} catch (error) {
35+
console.error('Unexpected error during test execution:', error);
36+
throw error; // Re-throw to fail the test
37+
}
38+
});
39+
});

exampleLitActions/test/fetch.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { expect } from 'chai';
2+
import { fetch } from '../src/fetch'; // Adjust the path as needed
3+
4+
describe('Lit Action fetch test', function() {
5+
// Increase timeout if needed for API calls
6+
this.timeout(30000);
7+
8+
it('should execute a fetch inside a Lit Action', async () => {
9+
const result = await fetch();
10+
11+
expect(result.success, 'Fetch should execute successfully').to.be.true;
12+
13+
if (!result.success) {
14+
expect(result.error, 'There should be no errors').to.be.undefined;
15+
}
16+
17+
// Add more assertions as needed
18+
expect(result.response).to.not.be.null;
19+
});
20+
});

0 commit comments

Comments
 (0)