Compare commits
1 Commits
fc9d96f242
...
93759190be
| Author | SHA1 | Date | |
|---|---|---|---|
|
93759190be
|
@@ -1,7 +1,4 @@
|
|||||||
import {
|
import { S3StorageAdapter, S3StorageConfig } from '@/lib/storage/storage.adapter';
|
||||||
S3StorageAdapter,
|
|
||||||
S3StorageConfig,
|
|
||||||
} from '@/lib/storage/storage.adapter';
|
|
||||||
import {
|
import {
|
||||||
DeleteObjectCommand,
|
DeleteObjectCommand,
|
||||||
PutObjectCommand,
|
PutObjectCommand,
|
||||||
@@ -69,16 +66,11 @@ describe('S3StorageAdapter', () => {
|
|||||||
|
|
||||||
await adapter.put(key, 'image/jpeg');
|
await adapter.put(key, 'image/jpeg');
|
||||||
|
|
||||||
const [, command] = jest.mocked(presigner.getSignedUrl).mock
|
const [, command] = jest.mocked(presigner.getSignedUrl).mock.calls[0];
|
||||||
.calls[0];
|
|
||||||
expect(command).toBeInstanceOf(PutObjectCommand);
|
expect(command).toBeInstanceOf(PutObjectCommand);
|
||||||
expect((command as PutObjectCommand).input.Bucket).toBe(
|
expect((command as PutObjectCommand).input.Bucket).toBe('test-bucket');
|
||||||
'test-bucket'
|
|
||||||
);
|
|
||||||
expect((command as PutObjectCommand).input.Key).toBe(key);
|
expect((command as PutObjectCommand).input.Key).toBe(key);
|
||||||
expect((command as PutObjectCommand).input.ContentType).toBe(
|
expect((command as PutObjectCommand).input.ContentType).toBe('image/jpeg');
|
||||||
'image/jpeg'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use 3600 second expiry', async () => {
|
it('should use 3600 second expiry', async () => {
|
||||||
@@ -88,8 +80,7 @@ describe('S3StorageAdapter', () => {
|
|||||||
|
|
||||||
await adapter.put('test-image.jpg', 'image/jpeg');
|
await adapter.put('test-image.jpg', 'image/jpeg');
|
||||||
|
|
||||||
const [, , options] = jest.mocked(presigner.getSignedUrl).mock
|
const [, , options] = jest.mocked(presigner.getSignedUrl).mock.calls[0];
|
||||||
.calls[0];
|
|
||||||
expect(options).toEqual({ expiresIn: 3600 });
|
expect(options).toEqual({ expiresIn: 3600 });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -103,8 +94,7 @@ describe('S3StorageAdapter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return correct presigned URL for different content types', async () => {
|
it('should return correct presigned URL for different content types', async () => {
|
||||||
const presignedUrl =
|
const presignedUrl = 'https://presigned-url.example.com/my-image.png';
|
||||||
'https://presigned-url.example.com/my-image.png';
|
|
||||||
jest.mocked(presigner.getSignedUrl).mockResolvedValue(presignedUrl);
|
jest.mocked(presigner.getSignedUrl).mockResolvedValue(presignedUrl);
|
||||||
|
|
||||||
const result = await adapter.put('my-image.png', 'image/png');
|
const result = await adapter.put('my-image.png', 'image/png');
|
||||||
|
|||||||
Reference in New Issue
Block a user