From e0bbcbb6edb7e772d2d07d19897d6c76a3c3bfb2 Mon Sep 17 00:00:00 2001 From: boarwell <34891695+boarwell@users.noreply.github.com> Date: Sat, 2 Oct 2021 13:33:36 +0900 Subject: [PATCH] Add tests for charset --- test/content-type.test.js | 24 ++++++++++++++++++++++++ test/public/charset/arabic.html | 21 +++++++++++++++++++++ test/public/charset/shift_jis.html | 17 +++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 test/public/charset/arabic.html create mode 100644 test/public/charset/shift_jis.html diff --git a/test/content-type.test.js b/test/content-type.test.js index 2bef08ec..b963c6ae 100644 --- a/test/content-type.test.js +++ b/test/content-type.test.js @@ -50,3 +50,27 @@ test('content type binary', (t) => { t.equal(headers['content-type'], 'application/wasm'); }); }); + +test('charset arabic', (t) => { + t.plan(3); + + const server = http.createServer( + ecstatic({root}) + ); + + checkHeaders(t, server, 'charset/arabic.html', (t, headers) => { + t.equal(headers['content-type'], 'text/html; charset=ISO-8859-6'); + }); +}); + +test('charset Shift_JIS', (t) => { + t.plan(3); + + const server = http.createServer( + ecstatic({root}) + ); + + checkHeaders(t, server, 'charset/shift_jis.html', (t, headers) => { + t.equal(headers['content-type'], 'text/html; charset=Shift_JIS'); + }); +}); diff --git a/test/public/charset/arabic.html b/test/public/charset/arabic.html new file mode 100644 index 00000000..35b8b78d --- /dev/null +++ b/test/public/charset/arabic.html @@ -0,0 +1,21 @@ + + + + + + HTML + + + +

Kokoro - Natsume Soseki

+

+

+

+ . + . . + + "". . + . +

+ + diff --git a/test/public/charset/shift_jis.html b/test/public/charset/shift_jis.html new file mode 100644 index 00000000..bfa4773d --- /dev/null +++ b/test/public/charset/shift_jis.html @@ -0,0 +1,17 @@ + + + + + + {HTMLt@C + + + +

- Ėڟ

+

@搶Ǝ

+

+

+ ͂̐lɐ搶ƌĂłB炱ł搶ƏŖ{͑łȂB͐Ԃ݂鉓ƂA̕ɂƂĎRłB͂̐l̋LĂыNƂɁAu搶vƂȂBMĂS͓łB悻悻Ȃǂ͂ƂĂgCɂȂȂB +

+ +