Skip to content

Commit

Permalink
chore: add test coverage for switch
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Jul 7, 2022
1 parent d729271 commit 80de7f2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/astro/test/astro-expr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,13 @@ describe('Expressions', () => {

expect($('#single-escape').html()).to.equal('Astro & Vite');
});

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

expect($('#red').length).to.equal(0);
expect($('#yellow').length).to.equal(1);
expect($('#blue').length).to.equal(0);
});
});
20 changes: 20 additions & 0 deletions packages/astro/test/fixtures/astro-expr/src/pages/switch.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
let title = 'Switch';
let colors = ['red', 'yellow', 'blue'];
---

<html>
<head>
<title>{title}</title>
</head>
<body>
{() => {
const color = colors[1];
switch (color) {
case 'red': return <div id="red">red</div>;
case 'yellow': return <div id="yellow">yellow</div>
case 'blue': return <div id="blue">blue</div>
}
}}
</body>
</html>

0 comments on commit 80de7f2

Please sign in to comment.