Skip to content

Commit

Permalink
fix async expectations in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vahidalizad committed Dec 11, 2024
1 parent 4a58f6b commit 74232a4
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions spec/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,31 +361,31 @@ describe('S3Adapter tests', () => {

it('should get using the baseUrl', async () => {
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'http://example.com/files/foo/bar/test.png'
);
});

it('should get direct to baseUrl', async () => {
options.baseUrlDirect = true;
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'http://example.com/files/test.png'
);
});

it('should get without directAccess', async () => {
options.directAccess = false;
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'http://my.server.com/parse/files/xxxx/test.png'
);
});

it('should go directly to amazon', async () => {
delete options.baseUrl;
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'https://my-bucket.s3.amazonaws.com/foo/bar/test.png'
);
});
Expand All @@ -412,31 +412,31 @@ describe('S3Adapter tests', () => {

it('should get using the baseUrl', async () => {
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'http://example.com/files/foo/bar/test.png'
);
});

it('should get direct to baseUrl', async () => {
options.baseUrlDirect = true;
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'http://example.com/files/test.png'
);
});

it('should get without directAccess', async () => {
options.directAccess = false;
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'http://my.server.com/parse/files/xxxx/test.png'
);
});

it('should go directly to amazon', async () => {
delete options.baseUrl;
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'https://my-bucket.s3.amazonaws.com/foo/bar/test.png'
);
});
Expand All @@ -459,7 +459,7 @@ describe('S3Adapter tests', () => {

it('should get using the baseUrl', async () => {
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'http://example.com/files/foo/bar/test.png'
);
});
Expand Down Expand Up @@ -496,23 +496,23 @@ describe('S3Adapter tests', () => {
it('should get direct to baseUrl', async () => {
options.baseUrlDirect = true;
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'http://example.com/files/test.png'
);
});

it('should get without directAccess', async () => {
options.directAccess = false;
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'http://my.server.com/parse/files/xxxx/test.png'
);
});

it('should go directly to amazon', async () => {
delete options.baseUrl;
const s3 = new S3Adapter('accessKey', 'secretKey', 'my-bucket', options);
expect(await s3.getFileLocation(testConfig, 'test.png')).toEqual(
await expectAsync(s3.getFileLocation(testConfig, 'test.png')).toBeResolvedTo(
'https://my-bucket.s3.amazonaws.com/foo/bar/test.png'
);
});
Expand Down

0 comments on commit 74232a4

Please sign in to comment.