summaryrefslogtreecommitdiff
path: root/packages/astro/test/preact-compat-component.test.js
blob: f0cd9e45fec9206f08e4d1ed595d09c5b1ad38b9 (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
import { expect } from 'chai';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';

describe('Preact compat component', () => {
	describe('Development', () => {
		let fixture;

		before(async () => {
			fixture = await loadFixture({
				root: './fixtures/preact-compat-component/',
			});
			await fixture.startDevServer();
		});

		it('Can load Counter', async () => {
			const html = await fixture.fetch('/').then((res) => res.text());
			const $ = cheerio.load(html);

			expect($('#counter-text').text()).to.be.eq('0');
		});
	});

	describe('Build', () => {
		let fixture;

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

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

			expect($('#counter-text').text()).to.be.eq('0');
		});
	});
});