Skip to content

Commit

Permalink
adding basic test coverage for cached images
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Sullivan committed Sep 29, 2022
1 parent bb8f634 commit 55e90b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/integrations/image/test/image-ssg.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import * as cheerio from 'cheerio';
import sizeOf from 'image-size';
import fs from 'fs/promises';
import { fileURLToPath } from 'url';
import { loadFixture } from './test-utils.js';

Expand Down Expand Up @@ -253,14 +254,17 @@ describe('SSG images - build', function () {
size: { width: 544, height: 184, type: 'jpg' },
},
].forEach(({ title, id, regex, size }) => {
it(title, () => {
it(title, async () => {
const image = $(id);

expect(image.attr('src')).to.match(regex);
expect(image.attr('width')).to.equal(size.width.toString());
expect(image.attr('height')).to.equal(size.height.toString());

verifyImage(image.attr('src'), size);

const url = new URL('./fixtures/basic-image/node_modules/.astro/image' + image.attr('src'), import.meta.url);
expect(await fs.stat(url), 'transformed image was cached').to.not.be.undefined;
});
});
});
Expand Down

0 comments on commit 55e90b7

Please sign in to comment.