Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion packages/astro/test/astro-directives.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { after, before, describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';

Expand Down Expand Up @@ -117,4 +117,52 @@ describe('Directives', async () => {
// Should not create Astro islands
assert.equal($('astro-island').length, 0);
});

it('set:html Fragment as slot (children)', async () => {
let res = await fixture.readFile('/set-html-children/index.html');
assert.equal(res.includes('Test'), true);
});
});

describe('set:html dev', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;

before(async () => {
fixture = await loadFixture({
root: './fixtures/astro-directives/',
});
});

describe('Development', () => {
/** @type {import('./test-utils').DevServer} */
let devServer;

before(async () => {
devServer = await fixture.startDevServer();
globalThis.TEST_FETCH = (fetch, url, init) => {
return fetch(fixture.resolveUrl(url), init);
};
});

after(async () => {
await devServer.stop();
});

it('set:html can take a fetch()', async () => {
let res = await fixture.fetch('/set-html-fetch');
assert.equal(res.status, 200);
let html = await res.text();
const $ = cheerio.load(html);
assert.equal($('#fetched-html').length, 1);
assert.equal($('#fetched-html').text(), 'works');
});

it('set:html Fragment as slot (children) in dev', async () => {
let res = await fixture.fetch('/set-html-children');
assert.equal(res.status, 200);
let html = await res.text();
assert.equal(html.includes('Test'), true);
});
});
});
4 changes: 2 additions & 2 deletions packages/astro/test/astro-external-files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ describe('External file references', () => {
let fixture;

before(async () => {
fixture = await loadFixture({ root: './fixtures/astro-external-files/' });
fixture = await loadFixture({ root: './fixtures/astro-public/' });
await fixture.build();
});

it('Build with external reference', async () => {
const html = await fixture.readFile('/index.html');
const html = await fixture.readFile('/external-files/index.html');
assert.equal(html.includes('<script src="/external-file.js"'), true);
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/test/astro-fallback.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ describe('Dynamic component fallback', () => {

before(async () => {
fixture = await loadFixture({
root: './fixtures/astro-fallback',
root: './fixtures/astro-expr/',
});
await fixture.build();
});

it('Shows static content', async () => {
const html = await fixture.readFile('/index.html');
const html = await fixture.readFile('/fallback/index.html');
const $ = cheerio.load(html);
assert.equal($('#fallback').text(), 'static');
});
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/test/astro-generator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ describe('Astro generator', () => {

before(async () => {
fixture = await loadFixture({
root: './fixtures/astro-generator/',
root: './fixtures/astro-basic/',
});
await fixture.build();
});

describe('build', () => {
it('Defines Astro.generator', async () => {
const html = await fixture.readFile(`/index.html`);
const html = await fixture.readFile(`/generator/index.html`);
const $ = cheerio.load(html);

assert.match($('meta[name="generator"]').attr('content'), /^Astro v/);
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/test/astro-slot-with-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ describe('Slots with client: directives', () => {
let fixture;

before(async () => {
fixture = await loadFixture({ root: './fixtures/astro-slot-with-client/' });
fixture = await loadFixture({ root: './fixtures/astro-expr/' });
await fixture.build();
});

it('Tags of dynamic tags works', async () => {
const html = await fixture.readFile('/index.html');
const html = await fixture.readFile('/slot-with-client/index.html');
const $ = cheerio.load(html);
assert.equal($('script').length, 2);
});

it('Astro slot tags are kept', async () => {
const html = await fixture.readFile('/index.html');
const html = await fixture.readFile('/slot-with-client/index.html');
const $ = cheerio.load(html);
assert.equal($('astro-slot').length, 1);
});
Expand Down
13 changes: 12 additions & 1 deletion packages/astro/test/core-image-svg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,18 @@ describe('astro:assets - SVG Components', () => {

before(async () => {
optimizedFixture = await loadFixture({
root: './fixtures/core-image-svg-optimized/',
root: './fixtures/core-image-svg/',
experimental: {
svgo: {
plugins: [
'preset-default',
{
name: 'removeViewBox',
active: false,
},
],
},
},
});

optimizedDevServer = await optimizedFixture.startDevServer();
Expand Down
7 changes: 6 additions & 1 deletion packages/astro/test/core-image.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,9 +888,14 @@ describe('astro:image', () => {
describe('support base option correctly', () => {
before(async () => {
fixture = await loadFixture({
root: './fixtures/core-image-base/',
root: './fixtures/core-image-ssg/',
image: {
service: testImageService(),
domains: [
'astro.build',
'avatars.githubusercontent.com',
'kaleidoscopic-biscotti-6fe98c.netlify.app',
],
},
base: '/blog',
});
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/test/css-order.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ describe('CSS production ordering', () => {

before(async () => {
fixture = await loadFixture({
root: './fixtures/css-order-transparent/',
root: './fixtures/css-order-layout/',
});
await fixture.build();
});

it('should compile styles in the same order as they are found', async () => {
const html = await fixture.readFile('/index.html');
const html = await fixture.readFile('/transparent/index.html');

// The component declares red background first, then yellow
assert.match(html, /body\{background:red\}body\{background:#ff0/);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import Slot from '../../components/Slot.astro';
import Slot from '../components/Slot.astro';
---

<html>
Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions packages/astro/test/fixtures/astro-fallback/astro.config.mjs

This file was deleted.

10 changes: 0 additions & 10 deletions packages/astro/test/fixtures/astro-fallback/package.json

This file was deleted.

8 changes: 0 additions & 8 deletions packages/astro/test/fixtures/astro-generator/package.json

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*",
"@astrojs/mdx": "workspace:*"
"@astrojs/mdx": "workspace:*",
"astro": "workspace:*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ const blog = defineCollection({
}),
});

export const collections = { blog };
export const collections = { blog };
11 changes: 0 additions & 11 deletions packages/astro/test/fixtures/core-image-base/package.json

This file was deleted.

Binary file not shown.
Binary file not shown.
18 changes: 0 additions & 18 deletions packages/astro/test/fixtures/core-image-base/src/content.config.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions packages/astro/test/fixtures/core-image-base/src/pages/index.astro

This file was deleted.

This file was deleted.

Loading
Loading