00fab4ce13
* refactor: add legacy.jsxInMarkdown flag to config * refactor: jsxInMarkdown -> astroFlavoredMarkdown * refactor: remove `markdown.mode` * feat: wire up legacy.astroFlavoredMarkdown * test: add legacy to astro-markdown fixture * test: remark autolinking * test: remark components * test: remark expressions * test: remark strictness * chore: remove "mode" from md component * chore: remove "mode: md" from tests * Fixing legacy MD tests, adding named slots tests for MDX pages * chore: update lock file * WIP: debugging named slots in MDX * fix: handle named slots in MDX properly * chore: re-enabling slots tests for MDX pages * fixing test validation for svelte & vue * removing unused Tailwind test * legacy flag for Markdown component tests * adding is:raw to Markdown component test * adding is:raw to all Markdown component test fixtures * can't use is:raw when nesting markdown components * another nested test can't use is:raw * one more <Markdown> test fix * fixing another JSX markdown component test * chore: add changeset * e2e tests were missing the legacy flag * removing the broken tailwind E2E markdown page Co-authored-by: Tony Sullivan <tony.f.sullivan@outlook.com> Co-authored-by: Nate Moore <nate@astro.build>
76 lines
2.5 KiB
JavaScript
76 lines
2.5 KiB
JavaScript
import { expect } from 'chai';
|
|
import * as cheerio from 'cheerio';
|
|
import { loadFixture } from './test-utils.js';
|
|
|
|
describe('Slots: Svelte', () => {
|
|
let fixture;
|
|
|
|
before(async () => {
|
|
fixture = await loadFixture({ root: './fixtures/slots-svelte/' });
|
|
await fixture.build();
|
|
});
|
|
|
|
it('Renders default slot', async () => {
|
|
const html = await fixture.readFile('/index.html');
|
|
const $ = cheerio.load(html);
|
|
|
|
expect($('#default-self-closing').text().trim()).to.equal('Fallback');
|
|
expect($('#default-empty').text().trim()).to.equal('Fallback');
|
|
expect($('#zero').text().trim()).to.equal('0');
|
|
expect($('#false').text().trim()).to.equal('');
|
|
expect($('#string').text().trim()).to.equal('');
|
|
expect($('#content').text().trim()).to.equal('Hello world!');
|
|
});
|
|
|
|
it('Renders named slot', async () => {
|
|
const html = await fixture.readFile('/index.html');
|
|
const $ = cheerio.load(html);
|
|
expect($('#named').text().trim()).to.equal('Fallback / Named');
|
|
});
|
|
|
|
it('Preserves dash-case slot', async () => {
|
|
const html = await fixture.readFile('/index.html');
|
|
const $ = cheerio.load(html);
|
|
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
|
|
});
|
|
|
|
describe('For Markdown Pages', () => {
|
|
it('Renders default slot', async () => {
|
|
const html = await fixture.readFile('/markdown/index.html');
|
|
const $ = cheerio.load(html);
|
|
expect($('#content').text().trim()).to.equal('Hello world!');
|
|
});
|
|
|
|
it('Renders named slot', async () => {
|
|
const html = await fixture.readFile('/markdown/index.html');
|
|
const $ = cheerio.load(html);
|
|
expect($('#named').text().trim()).to.equal('Fallback / Named');
|
|
});
|
|
|
|
it('Converts dash-case slot to camelCase', async () => {
|
|
const html = await fixture.readFile('/markdown/index.html');
|
|
const $ = cheerio.load(html);
|
|
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
|
|
});
|
|
});
|
|
|
|
describe('For MDX Pages', () => {
|
|
it('Renders default slot', async () => {
|
|
const html = await fixture.readFile('/mdx/index.html');
|
|
const $ = cheerio.load(html);
|
|
expect($('#content').text().trim()).to.equal('Hello world!');
|
|
});
|
|
|
|
it('Renders named slot', async () => {
|
|
const html = await fixture.readFile('/mdx/index.html');
|
|
const $ = cheerio.load(html);
|
|
expect($('#named').text().trim()).to.equal('Fallback / Named');
|
|
});
|
|
|
|
it('Preserves dash-case slot', async () => {
|
|
const html = await fixture.readFile('/index.html');
|
|
const $ = cheerio.load(html);
|
|
expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case');
|
|
});
|
|
});
|
|
});
|