diff --git a/spec/test.spec.js b/spec/test.spec.js index 5be1620..edb031b 100644 --- a/spec/test.spec.js +++ b/spec/test.spec.js @@ -451,42 +451,32 @@ describe('S3Adapter tests', () => { it('should save a file with metadata added', async () => { const s3 = makeS3Adapter(options); - s3._s3Client = { - createBucket: (callback) => callback(), - upload: (params, callback) => { - const { Metadata } = params; - expect(Metadata).toEqual({ foo: 'bar' }); - const data = { - Body: Buffer.from('hello world', 'utf8'), - }; - callback(null, data); - }, + s3._s3Client.upload = (params, callback) => { + const { Metadata } = params; + expect(Metadata).toEqual({ foo: 'bar' }); + const data = { + Body: Buffer.from('hello world', 'utf8'), + }; + callback(null, data); }; const fileName = 'randomFileName.txt'; const metadata = { foo: 'bar' }; - const value = await s3.createFile(fileName, 'hello world', 'text/utf8', { metadata }); - const url = new URL(value.Location); - expect(url.pathname.indexOf(fileName) > 13).toBe(true); + await s3.createFile(fileName, 'hello world', 'text/utf8', { metadata }); }); it('should save a file with tags added', async () => { const s3 = makeS3Adapter(options); - s3._s3Client = { - createBucket: (callback) => callback(), - upload: (params, callback) => { - const { Tagging } = params; - expect(Tagging).toEqual('foo=bar&baz=bin'); - const data = { - Body: Buffer.from('hello world', 'utf8'), - }; - callback(null, data); - }, + s3._s3Client.upload = (params, callback) => { + const { Tagging } = params; + expect(Tagging).toEqual('foo=bar&baz=bin'); + const data = { + Body: Buffer.from('hello world', 'utf8'), + }; + callback(null, data); }; const fileName = 'randomFileName.txt'; const tags = { foo: 'bar', baz: 'bin' }; - const value = await s3.createFile(fileName, 'hello world', 'text/utf8', { tags }); - const url = new URL(value.Location); - expect(url.pathname.indexOf(fileName) > 13).toBe(true); + await s3.createFile(fileName, 'hello world', 'text/utf8', { tags }); }); });