diff --git a/packages/astro/test/astro-expr.test.js b/packages/astro/test/astro-expr.test.js index c3c71450f55d..33a976d339e6 100644 --- a/packages/astro/test/astro-expr.test.js +++ b/packages/astro/test/astro-expr.test.js @@ -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); + }); }); diff --git a/packages/astro/test/fixtures/astro-expr/src/pages/switch.astro b/packages/astro/test/fixtures/astro-expr/src/pages/switch.astro new file mode 100644 index 000000000000..ded58613ecfa --- /dev/null +++ b/packages/astro/test/fixtures/astro-expr/src/pages/switch.astro @@ -0,0 +1,20 @@ +--- +let title = 'Switch'; +let colors = ['red', 'yellow', 'blue']; +--- + + + + {title} + + + {() => { + const color = colors[1]; + switch (color) { + case 'red': return
red
; + case 'yellow': return
yellow
+ case 'blue': return
blue
+ } + }} + +