Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stevestencil committed Jan 15, 2020
1 parent 7793f83 commit 8fa44fb
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions spec/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
});

Expand Down

0 comments on commit 8fa44fb

Please sign in to comment.