css-head-mdx.test.js — astro Source File
Architecture documentation for css-head-mdx.test.js, a javascript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 730fedba_2560_2ac2_86d0_c399a99c758f["css-head-mdx.test.js"] 0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"] 730fedba_2560_2ac2_86d0_c399a99c758f --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15 dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"] 730fedba_2560_2ac2_86d0_c399a99c758f --> dd4f09ce_3fd7_8295_f616_8876cda4555c e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] 730fedba_2560_2ac2_86d0_c399a99c758f --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 730fedba_2560_2ac2_86d0_c399a99c758f --> 6b0635f9_51ea_77aa_767b_7857878e98a6 b05fd4c1_a3ee_3301_adcd_43b49bae78f1["mdx"] 730fedba_2560_2ac2_86d0_c399a99c758f --> b05fd4c1_a3ee_3301_adcd_43b49bae78f1 deb87372_5629_35f8_9a54_e755a08f776a["cheerio"] 730fedba_2560_2ac2_86d0_c399a99c758f --> deb87372_5629_35f8_9a54_e755a08f776a cb315bcc_59d8_fa19_79aa_5da7cd3730c5["linkedom"] 730fedba_2560_2ac2_86d0_c399a99c758f --> cb315bcc_59d8_fa19_79aa_5da7cd3730c5 style 730fedba_2560_2ac2_86d0_c399a99c758f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import mdx from '@astrojs/mdx';
import * as cheerio from 'cheerio';
import { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';
describe('Head injection w/ MDX', () => {
let fixture;
before(async () => {
fixture = await loadFixture({
root: new URL('./fixtures/css-head-mdx/', import.meta.url),
integrations: [mdx()],
// test suite was authored when inlineStylesheets defaulted to never
build: { inlineStylesheets: 'never' },
});
});
describe('build', () => {
before(async () => {
await fixture.build();
});
it('injects content styles into head', async () => {
const html = await fixture.readFile('/indexThree/index.html');
const { document } = parseHTML(html);
const links = document.querySelectorAll('head link[rel=stylesheet]');
assert.equal(links.length, 1);
const scripts = document.querySelectorAll('script[type=module]');
assert.equal(scripts.length, 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]');
assert.equal(links.length, 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]');
assert.equal(links.length, 1);
const scripts = document.querySelectorAll('script[type=module]');
assert.equal(scripts.length, 1);
});
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]');
assert.equal(links.length, 1);
});
it('Using component but no layout', async () => {
const html = await fixture.readFile('/noLayoutWithComponent/index.html');
// Using cheerio here because linkedom doesn't support head tag injection
const $ = cheerio.load(html);
const headLinks = $('head link[rel=stylesheet]');
assert.equal(headLinks.length, 1);
const bodyLinks = $('body link[rel=stylesheet]');
assert.equal(bodyLinks.length, 0);
});
it('JSX component rendering Astro children within head buffering phase', async () => {
const html = await fixture.readFile('/posts/using-component/index.html');
// Using cheerio here because linkedom doesn't support head tag injection
const $ = cheerio.load(html);
const headLinks = $('head link[rel=stylesheet]');
assert.equal(headLinks.length, 1);
const bodyLinks = $('body link[rel=stylesheet]');
assert.equal(bodyLinks.length, 0);
});
it('Injection caused by delayed slots', async () => {
const html = await fixture.readFile('/componentwithtext/index.html');
// Using cheerio here because linkedom doesn't support head tag injection
const $ = cheerio.load(html);
const headLinks = $('head link[rel=stylesheet]');
assert.equal(headLinks.length, 1);
const bodyLinks = $('body link[rel=stylesheet]');
assert.equal(bodyLinks.length, 0);
});
});
});
Domain
Dependencies
- cheerio
- linkedom
- loadFixture
- mdx
- node:test
- strict
- test-utils.js
Source
Frequently Asked Questions
What does css-head-mdx.test.js do?
css-head-mdx.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does css-head-mdx.test.js depend on?
css-head-mdx.test.js imports 7 module(s): cheerio, linkedom, loadFixture, mdx, node:test, strict, test-utils.js.
Where is css-head-mdx.test.js in the architecture?
css-head-mdx.test.js is located at packages/integrations/mdx/test/css-head-mdx.test.js (domain: CoreAstro, directory: packages/integrations/mdx/test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free