diff options
Diffstat (limited to 'packages/astro')
3 files changed, 37 insertions, 0 deletions
diff --git a/packages/astro/test/fixtures/html-encoded-characters/snowpack.config.json b/packages/astro/test/fixtures/html-encoded-characters/snowpack.config.json new file mode 100644 index 000000000..8f034781d --- /dev/null +++ b/packages/astro/test/fixtures/html-encoded-characters/snowpack.config.json @@ -0,0 +1,3 @@ +{ + "workspaceRoot": "../../../../../" +} diff --git a/packages/astro/test/fixtures/html-encoded-characters/src/pages/index.astro b/packages/astro/test/fixtures/html-encoded-characters/src/pages/index.astro new file mode 100644 index 000000000..a174c3491 --- /dev/null +++ b/packages/astro/test/fixtures/html-encoded-characters/src/pages/index.astro @@ -0,0 +1,11 @@ +--- +--- +<html> +<head><title>HTML Encoded Characters</title></head> +<body> + <h1> Hello, world;</h1> + <div> + <p>Nested elements? No problem. </p> + </div> +</body> +</html> diff --git a/packages/astro/test/html-encoded-characters.test.js b/packages/astro/test/html-encoded-characters.test.js new file mode 100644 index 000000000..e12656a3c --- /dev/null +++ b/packages/astro/test/html-encoded-characters.test.js @@ -0,0 +1,23 @@ +import { suite } from 'uvu'; +import * as assert from 'uvu/assert'; +import { doc } from './test-utils.js'; +import { setup } from './helpers.js'; + +const HtmlEncodedChars = suite('HTML Encoded Characters'); + +setup(HtmlEncodedChars, './fixtures/html-encoded-characters'); + +HtmlEncodedChars("doesn't decode html entities", async ({ runtime }) => { + const result = await runtime.load('/'); + if (result.error) throw new Error(result.error); + + const $ = doc(result.contents); + // Note: although this may look like it's incorrectly decoding the chars, + // Cheerio is showing how the browsers _should_ interpret the HTML. If it + // wasn't working correctly, then the spaces would have been trimmed to a + // single space. + assert.equal($('h1').html(), ' Hello, world;'); + assert.equal($('div p').html(), 'Nested elements? No problem. '); +}); + +HtmlEncodedChars.run(); |