Skip to content

Commit 7afb0a2

Browse files
committed
Change spaces and adjust tests
1 parent 84e11a5 commit 7afb0a2

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
@@ -141,7 +141,7 @@ class S3Adapter {
141141
// For a given config object, filename, and data, store a file in S3
142142
// Returns a promise containing the S3 object creation response
143143
async createFile(filename, data, contentType, options = {}, config = {}) {
144-
144+
145145
let key_without_prefix = filename;
146146
if (this._generateKey instanceof Function) {
147147
try {
@@ -150,13 +150,13 @@ class S3Adapter {
150150
throw new Error(e); // throw error if generateKey function fails
151151
}
152152
}
153-
153+
154154
const params = {
155155
Bucket: this._bucket,
156156
Key: this._bucketPrefix + key_without_prefix,
157157
Body: data,
158158
};
159-
159+
160160
if (this._fileAcl) {
161161
if (this._fileAcl === 'none') {
162162
delete params.ACL;

spec/test.spec.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -875,34 +875,35 @@ describe('S3Adapter tests', () => {
875875
};
876876
const s3 = new S3Adapter(options);
877877
s3._s3Client = s3ClientMock;
878-
879878
// Mock getFileLocation to return a presigned URL
880879
spyOn(s3, 'getFileLocation').and.returnValue(Promise.resolve('https://presigned-url.com/file.txt'));
881-
880+
882881
const result = await s3.createFile(
883-
'file.txt',
884-
'hello world',
885-
'text/utf8',
882+
'file.txt',
883+
'hello world',
884+
'text/utf8',
886885
{},
887886
{ mount: 'http://example.com', applicationId: 'test123' }
888887
);
889-
890-
expect(result.url).toBe('https://presigned-url.com/file.txt');
891-
expect(result.location).toBeDefined();
892-
expect(result.name).toBe('file.txt');
893-
expect(result.s3_response).toBeDefined();
888+
889+
expect(result).toEqual({
890+
location: jasmine.any(String),
891+
name: 'file.txt',
892+
s3_response: jasmine.any(Object),
893+
url: 'https://presigned-url.com/file.txt'
894+
});
894895
});
895896

896897
it('should handle generateKey function errors', async () => {
897898
const options = {
898899
bucket: 'bucket-1',
899900
generateKey: () => {
900-
throw new Error('Generate key failed');
901+
throw 'Generate key failed';
901902
}
902903
};
903904
const s3 = new S3Adapter(options);
904905
s3._s3Client = s3ClientMock;
905-
906+
906907
await expectAsync(
907908
s3.createFile('file.txt', 'hello world', 'text/utf8', {})
908909
).toBeRejectedWithError('Generate key failed');

0 commit comments

Comments
 (0)