astro-doctype.test.js — astro Source File
Architecture documentation for astro-doctype.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR db037638_d47b_5178_9c6f_0bfc7d8b6508["astro-doctype.test.js"] 0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"] db037638_d47b_5178_9c6f_0bfc7d8b6508 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15 dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"] db037638_d47b_5178_9c6f_0bfc7d8b6508 --> dd4f09ce_3fd7_8295_f616_8876cda4555c e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] db037638_d47b_5178_9c6f_0bfc7d8b6508 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] db037638_d47b_5178_9c6f_0bfc7d8b6508 --> 6b0635f9_51ea_77aa_767b_7857878e98a6 deb87372_5629_35f8_9a54_e755a08f776a["cheerio"] db037638_d47b_5178_9c6f_0bfc7d8b6508 --> deb87372_5629_35f8_9a54_e755a08f776a style db037638_d47b_5178_9c6f_0bfc7d8b6508 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
describe('Doctype', () => {
let fixture;
before(async () => {
fixture = await loadFixture({ root: './fixtures/astro-doctype/' });
await fixture.build();
});
it('Automatically prepends the standards mode doctype', async () => {
const html = await fixture.readFile('/prepend/index.html');
// test that Doctype always included
assert.match(html, /^<!DOCTYPE html>/i);
});
it('No attributes added when doctype is provided by user', async () => {
const html = await fixture.readFile('/provided/index.html');
// test that Doctype always included
assert.match(html, /^<!DOCTYPE html>/i);
});
it.skip('Preserves user provided doctype', async () => {
const html = await fixture.readFile('/preserve/index.html');
// test that Doctype included was preserved
assert.match(
html,
/^<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/html4\/loose.dtd">/i,
);
});
it('User provided doctype is case insensitive', async () => {
const html = await fixture.readFile('/capital/index.html');
// test 1: Doctype left alone
assert.match(html, /^<!DOCTYPE html>/i);
// test 2: no closing tag
assert.doesNotMatch(html, /<\/!DOCTYPE>/i);
});
it.skip('Doctype can be provided in a layout', async () => {
const html = await fixture.readFile('/in-layout/index.html');
// test 1: doctype is at the front
assert.match(html, /^<!DOCTYPE html>/i);
// test 2: A link inside of the head
const $ = cheerio.load(html);
assert.equal($('head link').length, 1);
});
it('Doctype is added in a layout without one', async () => {
const html = await fixture.readFile('/in-layout-no-doctype/index.html');
// test that doctype is at the front
assert.match(html, /^<!DOCTYPE html>/i);
});
it('Doctype is added in a layout used with markdown pages', async () => {
const html = await fixture.readFile('/in-layout-article/index.html');
// test 1: doctype is at the front
assert.match(html, /^<!DOCTYPE html>/i);
// test 2: A link inside of the head
const $ = cheerio.load(html);
assert.equal($('head link').length, 1);
});
});
Domain
Dependencies
- cheerio
- loadFixture
- node:test
- strict
- test-utils.js
Source
Frequently Asked Questions
What does astro-doctype.test.js do?
astro-doctype.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does astro-doctype.test.js depend on?
astro-doctype.test.js imports 5 module(s): cheerio, loadFixture, node:test, strict, test-utils.js.
Where is astro-doctype.test.js in the architecture?
astro-doctype.test.js is located at packages/astro/test/astro-doctype.test.js (domain: IntegrationAdapters, directory: packages/astro/test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free