Skip to content

Commit 816c780

Browse files
committed
Change spaces and adjust tests
1 parent 429c9f1 commit 816c780

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class S3Adapter {
140140
// For a given config object, filename, and data, store a file in S3
141141
// Returns a promise containing the S3 object creation response
142142
async createFile(filename, data, contentType, options = {}, config = {}) {
143-
143+
144144
let key_without_prefix = filename;
145145
if (this._generateKey instanceof Function) {
146146
try {
@@ -149,13 +149,13 @@ class S3Adapter {
149149
throw new Error(e); // throw error if generateKey function fails
150150
}
151151
}
152-
152+
153153
const params = {
154154
Bucket: this._bucket,
155155
Key: this._bucketPrefix + key_without_prefix,
156156
Body: data,
157157
};
158-
158+
159159
if (this._fileAcl) {
160160
if (this._fileAcl === 'none') {
161161
delete params.ACL;

spec/test.spec.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -842,34 +842,35 @@ describe('S3Adapter tests', () => {
842842
};
843843
const s3 = new S3Adapter(options);
844844
s3._s3Client = s3ClientMock;
845-
846845
// Mock getFileLocation to return a presigned URL
847846
spyOn(s3, 'getFileLocation').and.returnValue(Promise.resolve('https://presigned-url.com/file.txt'));
848-
847+
849848
const result = await s3.createFile(
850-
'file.txt',
851-
'hello world',
852-
'text/utf8',
849+
'file.txt',
850+
'hello world',
851+
'text/utf8',
853852
{},
854853
{ mount: 'http://example.com', applicationId: 'test123' }
855854
);
856-
857-
expect(result.url).toBe('https://presigned-url.com/file.txt');
858-
expect(result.location).toBeDefined();
859-
expect(result.name).toBe('file.txt');
860-
expect(result.s3_response).toBeDefined();
855+
856+
expect(result).toEqual({
857+
location: jasmine.any(String),
858+
name: 'file.txt',
859+
s3_response: jasmine.any(Object),
860+
url: 'https://presigned-url.com/file.txt'
861+
});
861862
});
862863

863864
it('should handle generateKey function errors', async () => {
864865
const options = {
865866
bucket: 'bucket-1',
866867
generateKey: () => {
867-
throw new Error('Generate key failed');
868+
throw 'Generate key failed';
868869
}
869870
};
870871
const s3 = new S3Adapter(options);
871872
s3._s3Client = s3ClientMock;
872-
873+
873874
await expectAsync(
874875
s3.createFile('file.txt', 'hello world', 'text/utf8', {})
875876
).toBeRejectedWithError('Generate key failed');

0 commit comments

Comments
 (0)