Skip to content

Commit

Permalink
Added tests for solid
Browse files Browse the repository at this point in the history
  • Loading branch information
elite174 committed Oct 6, 2024
1 parent 9be548c commit da70fb2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let count = 1;

export default function RenderCount() {
return (
<>
<div id="render-count">{count++}</div>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Counter as DepCounter } from '@test/solid-jsx-component';
import Hello from '../components/Hello.jsx';
import ProxyComponent from '../components/ProxyComponent.jsx';
import WithNewlines from '../components/WithNewlines.jsx';
import RenderCount from '../components/RenderCount.jsx';
---
<html>
<head><title>Solid</title></head>
Expand All @@ -14,6 +15,7 @@ import WithNewlines from '../components/WithNewlines.jsx';
<Router />
<ProxyComponent client:load />
<DepCounter client:load />
<RenderCount client:load />
</div>
</body>
</html>
7 changes: 7 additions & 0 deletions packages/astro/test/solid-component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ describe.skip('Solid component build', { todo: 'Check why an error is thrown.' }
assert.equal($('#proxy-component').text(), 'Hello world');
});

it('Renders the component only once on the server', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);

assert.equal($('#render-count').text(), '1');
});

// ssr-client-none.astro
it('Supports server only components', async () => {
const html = await fixture.readFile('ssr-client-none/index.html');
Expand Down

0 comments on commit da70fb2

Please sign in to comment.