summaryrefslogtreecommitdiff
path: root/packages/astro/test/jsx.test.js
blob: 41671699cf1912df513dc84e216683660b81d940 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { expect } from 'chai';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';

describe('jsx-runtime', () => {
	let fixture;

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

	it('Can load simple JSX components', async () => {
		const html = await fixture.readFile('/component/index.html');
		const $ = cheerio.load(html);

		expect($('#basic').text()).to.equal('Basic');
		expect($('#named').text()).to.equal('Named');
	});

	it('Can load Preact component inside Astro JSX', async () => {
		const html = await fixture.readFile('/frameworks/index.html');
		const $ = cheerio.load(html);

		expect($('#has-preact #preact').length).to.equal(1);
		expect($('#preact').text()).to.include('Preact');
	});

	it('Can load React component inside Astro JSX', async () => {
		const html = await fixture.readFile('/frameworks/index.html');
		const $ = cheerio.load(html);

		expect($('#has-react #react').length).to.equal(1);
		expect($('#react').text()).to.include('React');
	});

	it('Can load Solid component inside Astro JSX', async () => {
		const html = await fixture.readFile('/frameworks/index.html');
		const $ = cheerio.load(html);

		expect($('#has-solid #solid').length).to.equal(1);
		expect($('#solid').text()).to.include('Solid');
	});

	it('Can load Svelte component inside Astro JSX', async () => {
		const html = await fixture.readFile('/frameworks/index.html');
		const $ = cheerio.load(html);

		expect($('#has-svelte #svelte').length).to.equal(1);
		expect($('#svelte').text()).to.include('Svelte');
	});

	it('Can load Vue component inside Astro JSX', async () => {
		const html = await fixture.readFile('/frameworks/index.html');
		const $ = cheerio.load(html);

		expect($('#has-vue #vue').length).to.equal(1);
		expect($('#vue').text()).to.include('Vue');
	});
});