|
1 | 1 | 'use strict' |
2 | 2 |
|
3 | | -var expect = require('chai').expect |
4 | | -var path = require('path') |
5 | | -var fs = require('fs') |
| 3 | +const { expect } = require('chai') |
| 4 | +const path = require('path') |
| 5 | +const fs = require('fs') |
6 | 6 |
|
7 | | -var toUTF8 = require('../index') |
| 7 | +const toUTF8 = require('../index')('utf-8') |
8 | 8 |
|
9 | 9 | describe('Encoding Converter', function () { |
10 | 10 | it('properly decodes Shift-JIS html documents', function () { |
11 | | - var buffer = loadExample('51242_54045.html') |
12 | | - var output = toUTF8(buffer, 'text/html') |
| 11 | + const buffer = loadExample('51242_54045.html') |
| 12 | + const output = toUTF8(buffer, 'text/html') |
13 | 13 |
|
14 | 14 | expect(output).to.contain('或る日の小せん') |
15 | 15 | }) |
16 | 16 |
|
17 | 17 | it('properly decodes Windows-1250 html documents', function () { |
18 | | - var buffer = loadExample('rp.pl.html') |
19 | | - var output = toUTF8(buffer, 'windows-1250') |
| 18 | + const buffer = loadExample('rp.pl.html') |
| 19 | + const output = toUTF8(buffer, 'windows-1250') |
20 | 20 |
|
21 | 21 | expect(output).to.contain('majątków') |
22 | 22 | }) |
23 | 23 |
|
24 | 24 | it('guesses encoding even without meta tags or content type', function () { |
25 | | - var buffer = loadExample('shiftjis.no.meta.html') |
26 | | - var output = toUTF8(buffer, 'text/html') |
| 25 | + const buffer = loadExample('shiftjis.no.meta.html') |
| 26 | + const output = toUTF8(buffer, 'text/html') |
27 | 27 |
|
28 | 28 | expect(output).to.contain('次常用國字標準字體表') |
29 | 29 | }) |
30 | 30 |
|
31 | 31 | it('works for documents which already are UTF-8', function () { |
32 | | - var buffer = loadExample('utf8.with.meta.html') |
33 | | - var output = toUTF8(buffer, 'text/html') |
| 32 | + const buffer = loadExample('utf8.with.meta.html') |
| 33 | + const output = toUTF8(buffer, 'text/html') |
34 | 34 |
|
35 | 35 | expect(output).to.contain('日本語') |
36 | 36 | }) |
37 | 37 |
|
38 | 38 | it('Replace charset from the original buffer', function () { |
39 | | - var buffer = loadExample('51242_54045.html') |
40 | | - var output = toUTF8(buffer, 'text/html') |
| 39 | + const buffer = loadExample('51242_54045.html') |
| 40 | + const output = toUTF8(buffer, 'text/html') |
41 | 41 |
|
42 | 42 | expect(output).to.contain( |
43 | 43 | '<meta http-equiv="Content-Type" content="text/html;utf-8" />' |
|
0 commit comments