Skip to content

Commit

Permalink
🧪 add test for prescaled media
Browse files Browse the repository at this point in the history
updates the test suite for the condition where an original file has the scaling "-100x100" signature of a resized render file
  • Loading branch information
jdub233 committed Jul 24, 2024
1 parent bf8d263 commit 362a960
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/getOrCreateObject/getOrCreateObject.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ s3Mock.on(GetObjectCommand, {
Body: singlePixelJpgReadable,
});

// Define a pre-scaled object in the bucket,
// with a scale factor baked into the name of the original.
s3Mock.on(GetObjectCommand, {
Bucket: 'test-bucket',
Key: 'original_media/www.bu.edu/somesite/files/01/prescaled-758x460.jpg',
}).resolves({
Body: singlePixelJpgReadable,
});

describe('getOrCreateObject', () => {
it('should return an object if it exists', async () => {
const result = await getOrCreateObject(
Expand Down Expand Up @@ -89,4 +98,15 @@ describe('getOrCreateObject', () => {
);
expect(result.Code).toEqual('NoSuchKey');
});

it('should return a pre-scaled original object if it exists', async () => {
const result = await getOrCreateObject(
{
url: 'https://example-1111.s3-object-lambda.us-east-1.amazonaws.com/somesite/files/01/prescaled-758x460.jpg',
headers: { },
},
'www.bu.edu',
);
expect(result.Body).toBeDefined();
});
});

0 comments on commit 362a960

Please sign in to comment.