mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
test: add test in the Node adapter for astro:assets (#7734)
This commit is contained in:
parent
78549e9e7b
commit
477f2af527
4 changed files with 59 additions and 0 deletions
13
packages/integrations/node/test/fixtures/image/package.json
vendored
Normal file
13
packages/integrations/node/test/fixtures/image/package.json
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "@test/nodejs-image",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*",
|
||||
"@astrojs/node": "workspace:*"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "astro build",
|
||||
"preview": "astro preview"
|
||||
}
|
||||
}
|
BIN
packages/integrations/node/test/fixtures/image/src/assets/some_penguin.png
vendored
Normal file
BIN
packages/integrations/node/test/fixtures/image/src/assets/some_penguin.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 315 KiB |
6
packages/integrations/node/test/fixtures/image/src/pages/index.astro
vendored
Normal file
6
packages/integrations/node/test/fixtures/image/src/pages/index.astro
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
import { Image } from "astro:assets";
|
||||
import penguin from "../assets/some_penguin.png";
|
||||
---
|
||||
|
||||
<Image src={penguin} alt="Penguins" width={50} />
|
40
packages/integrations/node/test/image.test.js
Normal file
40
packages/integrations/node/test/image.test.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { expect } from 'chai';
|
||||
import nodejs from '../dist/index.js';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
describe('Image endpoint', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
let fixture;
|
||||
let devPreview;
|
||||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/image/',
|
||||
output: 'server',
|
||||
adapter: nodejs({ mode: 'standalone' }),
|
||||
experimental: {
|
||||
assets: true,
|
||||
},
|
||||
});
|
||||
await fixture.build();
|
||||
devPreview = await fixture.preview();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await devPreview.stop();
|
||||
});
|
||||
|
||||
it('it returns images', async () => {
|
||||
const res = await fixture.fetch('/');
|
||||
expect(res.status).to.equal(200);
|
||||
|
||||
const resImage = await fixture.fetch(
|
||||
'/_image?href=/_astro/some_penguin.97ef5f92.png&w=50&f=webp'
|
||||
);
|
||||
|
||||
console.log(resImage);
|
||||
const content = resImage.text();
|
||||
console.log(content);
|
||||
expect(resImage.status).to.equal(200);
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue