summaryrefslogtreecommitdiff
path: root/packages/astro
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro')
-rw-r--r--packages/astro/test/fixtures/html-encoded-characters/snowpack.config.json3
-rw-r--r--packages/astro/test/fixtures/html-encoded-characters/src/pages/index.astro11
-rw-r--r--packages/astro/test/html-encoded-characters.test.js23
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>&nbsp;&nbsp;&nbsp;Hello, world&semi;</h1>
+ <div>
+ <p>Nested elements&quest; No problem&period;&nbsp;</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(), '&nbsp;&nbsp;&nbsp;Hello, world;');
+ assert.equal($('div p').html(), 'Nested elements? No problem.&nbsp;');
+});
+
+HtmlEncodedChars.run();