Skip to content

Commit

Permalink
Add tests for charset
Browse files Browse the repository at this point in the history
  • Loading branch information
boarwell committed Oct 19, 2021
1 parent b32b8a4 commit 5dfc780
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/content-type.test.js
Expand Up @@ -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');
});
});
21 changes: 21 additions & 0 deletions test/public/charset/arabic.html
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="ISO-8859-6" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>العربية HTML</title>
</head>

<body>
<h1>Kokoro - Natsume Soseki</h1>
<h2>المعلم وأنا</h2>
<h3>واحد</h3>
<p>
اعتدت أن أسمي هذا الشخص مدرسًا. حتى هنا ، لا يمكنني الاعتراف باسمي الحقيقي
بمجرد الكتابة مع المعلم. هذا طبيعي بالنسبة لي أكثر من الإحجام عن العالم.
في كل مرة أتذكر فيها ذاكرة ذلك الشخص ، أريد على الفور أن أطلق عليه اسم
"المعلم". حتى لو كتبت فرشاة ، فإن مشاعري هي نفسها. لا أشعر برغبة في
استخدام الاختصارات بمعزل.
</p>
</body>
</html>
17 changes: 17 additions & 0 deletions test/public/charset/shift_jis.html
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="shift_jis" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>日本語のHTMLファイル</title>
</head>

<body>
<h1>こころ - 夏目漱石</h1>
<h2>上 先生と私</h2>
<h3></h3>
<p>
私はその人を常に先生と呼んでいた。だからここでもただ先生と書くだけで本名は打ち明けない。これは世間を憚かる遠慮というよりも、その方が私にとって自然だからである。私はその人の記憶を呼び起すごとに、すぐ「先生」といいたくなる。筆を執っても心持は同じ事である。よそよそしい頭文字などはとても使う気にならない。
</p>
</body>
</html>

0 comments on commit 5dfc780

Please sign in to comment.