Skip to content

Commit 5dfc780

Browse files
committed
Add tests for charset
1 parent b32b8a4 commit 5dfc780

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

test/content-type.test.js

+24
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,27 @@ test('content type binary', (t) => {
5050
t.equal(headers['content-type'], 'application/wasm');
5151
});
5252
});
53+
54+
test('charset arabic', (t) => {
55+
t.plan(3);
56+
57+
const server = http.createServer(
58+
ecstatic({root})
59+
);
60+
61+
checkHeaders(t, server, 'charset/arabic.html', (t, headers) => {
62+
t.equal(headers['content-type'], 'text/html; charset=ISO-8859-6');
63+
});
64+
});
65+
66+
test('charset Shift_JIS', (t) => {
67+
t.plan(3);
68+
69+
const server = http.createServer(
70+
ecstatic({root})
71+
);
72+
73+
checkHeaders(t, server, 'charset/shift_jis.html', (t, headers) => {
74+
t.equal(headers['content-type'], 'text/html; charset=Shift_JIS');
75+
});
76+
});

test/public/charset/arabic.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="ar">
3+
<head>
4+
<meta charset="ISO-8859-6" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>العربية HTML</title>
7+
</head>
8+
9+
<body>
10+
<h1>Kokoro - Natsume Soseki</h1>
11+
<h2>المعلم وأنا</h2>
12+
<h3>واحد</h3>
13+
<p>
14+
اعتدت أن أسمي هذا الشخص مدرسًا. حتى هنا ، لا يمكنني الاعتراف باسمي الحقيقي
15+
بمجرد الكتابة مع المعلم. هذا طبيعي بالنسبة لي أكثر من الإحجام عن العالم.
16+
في كل مرة أتذكر فيها ذاكرة ذلك الشخص ، أريد على الفور أن أطلق عليه اسم
17+
"المعلم". حتى لو كتبت فرشاة ، فإن مشاعري هي نفسها. لا أشعر برغبة في
18+
استخدام الاختصارات بمعزل.
19+
</p>
20+
</body>
21+
</html>

test/public/charset/shift_jis.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="ja">
3+
<head>
4+
<meta charset="shift_jis" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>日本語のHTMLファイル</title>
7+
</head>
8+
9+
<body>
10+
<h1>こころ - 夏目漱石</h1>
11+
<h2>上 先生と私</h2>
12+
<h3></h3>
13+
<p>
14+
私はその人を常に先生と呼んでいた。だからここでもただ先生と書くだけで本名は打ち明けない。これは世間を憚かる遠慮というよりも、その方が私にとって自然だからである。私はその人の記憶を呼び起すごとに、すぐ「先生」といいたくなる。筆を執っても心持は同じ事である。よそよそしい頭文字などはとても使う気にならない。
15+
</p>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)