summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/test/css-head-mdx.test.js
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2023-02-07 10:56:32 -0500
committerGravatar GitHub <noreply@github.com> 2023-02-07 10:56:32 -0500
commitd1f5611febfd020cca4078c71bafe599015edd16 (patch)
treef8fc9ce932f2dcaa559602ef66b77afa795b764f /packages/integrations/mdx/test/css-head-mdx.test.js
parentcee70f5c6ac9b0d2edc1f8a6f8f5043605576026 (diff)
downloadastro-d1f5611febfd020cca4078c71bafe599015edd16.tar.gz
astro-d1f5611febfd020cca4078c71bafe599015edd16.tar.zst
astro-d1f5611febfd020cca4078c71bafe599015edd16.zip
Add additional scoping for head buffering (#6152)
* Add additional scoping for head buffering * Add test for direct usage of nested component * Add special scoping for Astro.scopes.render() * Generate propagation map during the build * Move to a maybeHead instruction * Properly serialize for SSR * More conservative scoping * Maybe had should honor result._metadata.hasRenderedHead * Properly type slots * Allow template result to be passed * Add changeset
Diffstat (limited to 'packages/integrations/mdx/test/css-head-mdx.test.js')
-rw-r--r--packages/integrations/mdx/test/css-head-mdx.test.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/integrations/mdx/test/css-head-mdx.test.js b/packages/integrations/mdx/test/css-head-mdx.test.js
index 2b1dcdfe7..c38f23701 100644
--- a/packages/integrations/mdx/test/css-head-mdx.test.js
+++ b/packages/integrations/mdx/test/css-head-mdx.test.js
@@ -29,5 +29,32 @@ describe('Head injection w/ MDX', () => {
const scripts = document.querySelectorAll('head script[type=module]');
expect(scripts).to.have.a.lengthOf(1);
});
+
+ it('injects into the head for content collections', async () => {
+ const html = await fixture.readFile('/posts/test/index.html');
+ const { document } = parseHTML(html);
+
+ const links = document.querySelectorAll('head link[rel=stylesheet]');
+ expect(links).to.have.a.lengthOf(1);
+ });
+
+ it('injects content from a component using Content#render()', async () => {
+ const html = await fixture.readFile('/DirectContentUsage/index.html');
+ const { document } = parseHTML(html);
+
+ const links = document.querySelectorAll('head link[rel=stylesheet]');
+ expect(links).to.have.a.lengthOf(1);
+
+ const scripts = document.querySelectorAll('head script[type=module]');
+ expect(scripts).to.have.a.lengthOf(2);
+ });
+
+ it('Using component using slots.render() API', async () => {
+ const html = await fixture.readFile('/remote/index.html');
+ const { document } = parseHTML(html);
+
+ const links = document.querySelectorAll('head link[rel=stylesheet]');
+ expect(links).to.have.a.lengthOf(1);
+ });
});
});