major style changes - tests

This commit is contained in:
Dmitry Shirokov 2013-11-22 15:40:19 +11:00
parent 1a7da87ec4
commit 17aebe7b28
6 changed files with 196 additions and 201 deletions

View File

@ -1,30 +1,30 @@
var assert = require('assert'),
chardet = require('../'),
fs = require('fs');
chardet = require('../'),
fs = require('fs');
describe('chardet', function() {
var path = __dirname + '/data/encodings/utf8';
var path = __dirname + '/data/encodings/utf8';
describe('#detect', function() {
it('should detect encoding', function() {
assert.equal(chardet.detect(fs.readFileSync(path)), 'UTF-8');
});
describe('#detect', function() {
it('should detect encoding', function() {
assert.equal(chardet.detect(fs.readFileSync(path)), 'UTF-8');
});
});
describe('#detectFile', function() {
it('should detect encoding', function(done) {
chardet.detectFile(path, function(err, res) {
assert.equal(err, null);
assert.equal(res, 'UTF-8');
done();
});
});
describe('#detectFile', function() {
it('should detect encoding', function(done) {
chardet.detectFile(path, function(err, res) {
assert.equal(err, null);
assert.equal(res, 'UTF-8');
done();
});
});
});
describe('#detectFileSync', function() {
it('should detect encoding', function() {
assert.equal(chardet.detectFileSync(path), 'UTF-8');
});
describe('#detectFileSync', function() {
it('should detect encoding', function() {
assert.equal(chardet.detectFileSync(path), 'UTF-8');
});
});
});
});

View File

@ -1,29 +1,28 @@
var assert = require('assert'),
chardet = require('../../');
chardet = require('../../');
describe('ISO-2022', function() {
var base = __dirname + '/../data/encodings';
var base = __dirname + '/../data/encodings';
it('should return ISO-2022-JP', function() {
assert.equal(
chardet.detectFileSync(base + '/iso2022jp'),
'ISO-2022-JP'
);
});
it('should return ISO-2022-JP', function() {
assert.equal(
chardet.detectFileSync(base + '/iso2022jp'),
'ISO-2022-JP'
);
});
it('should return ISO-2022-KR', function() {
assert.equal(
chardet.detectFileSync(base + '/iso2022kr'),
'ISO-2022-KR'
);
});
it('should return ISO-2022-KR', function() {
assert.equal(
chardet.detectFileSync(base + '/iso2022kr'),
'ISO-2022-KR'
);
});
it('should return ISO-2022-CN', function() {
assert.equal(
chardet.detectFileSync(base + '/iso2022cn'),
'ISO-2022-CN'
);
});
});
it('should return ISO-2022-CN', function() {
assert.equal(
chardet.detectFileSync(base + '/iso2022cn'),
'ISO-2022-CN'
);
});
});

View File

@ -1,44 +1,43 @@
var assert = require('assert'),
chardet = require('../../');
chardet = require('../../');
describe('Multybyte Character Sets', function() {
var base = __dirname + '/../data/encodings';
var base = __dirname + '/../data/encodings';
it('should return SHIFT-JIS', function() {
assert.equal(
chardet.detectFileSync(base + '/shiftjis'),
'Shift-JIS'
);
});
it('should return SHIFT-JIS', function() {
assert.equal(
chardet.detectFileSync(base + '/shiftjis'),
'Shift-JIS'
);
});
it('should return GB18030', function() {
assert.equal(
chardet.detectFileSync(base + '/gb18030'),
'GB18030'
);
});
it('should return GB18030', function() {
assert.equal(
chardet.detectFileSync(base + '/gb18030'),
'GB18030'
);
});
it('should return Big5', function() {
assert.equal(
chardet.detectFileSync(base + '/big5'),
'Big5'
);
});
it('should return Big5', function() {
assert.equal(
chardet.detectFileSync(base + '/big5'),
'Big5'
);
});
it('should return EUC-JP', function() {
assert.equal(
chardet.detectFileSync(base + '/euc_jp'),
'EUC-JP'
);
});
it('should return EUC-JP', function() {
assert.equal(
chardet.detectFileSync(base + '/euc_jp'),
'EUC-JP'
);
});
it('should return EUC-KR', function() {
assert.equal(
chardet.detectFileSync(base + '/euc_kr'),
'EUC-KR'
);
});
it('should return EUC-KR', function() {
assert.equal(
chardet.detectFileSync(base + '/euc_kr'),
'EUC-KR'
);
});
});
});

View File

@ -1,112 +1,111 @@
var assert = require('assert'),
chardet = require('../../');
chardet = require('../../');
describe('Singlebyte Character Sets', function() {
var base = __dirname + '/../data/encodings';
var base = __dirname + '/../data/encodings';
it('should return ISO-8859-1 (English)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88591_en'), 'ISO-8859-1'
);
});
it('should return ISO-8859-1 (English)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88591_en'), 'ISO-8859-1'
);
});
it('should return ISO-8859-2 (Czech)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88592_cs'), 'ISO-8859-2'
);
});
it('should return ISO-8859-2 (Czech)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88592_cs'), 'ISO-8859-2'
);
});
it('should return ISO-8859-3');
it('should return ISO-8859-4');
it('should return ISO-8859-3');
it('should return ISO-8859-4');
it('should return ISO-8859-5 (Russian)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88595_ru'), 'ISO-8859-5'
);
});
it('should return ISO-8859-5 (Russian)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88595_ru'), 'ISO-8859-5'
);
});
it('should return ISO-8859-6 (Arabic)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88596_ar'), 'ISO-8859-6'
);
});
it('should return ISO-8859-6 (Arabic)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88596_ar'), 'ISO-8859-6'
);
});
it('should return ISO-8859-7 (Greek)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88597_el'), 'ISO-8859-7'
);
});
it('should return ISO-8859-7 (Greek)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88597_el'), 'ISO-8859-7'
);
});
it('should return ISO-8859-8 (Hebrew)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88598_he'), 'ISO-8859-8'
);
});
it('should return ISO-8859-8 (Hebrew)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88598_he'), 'ISO-8859-8'
);
});
it('should return ISO-8859-9 (Turkish)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88599_tr'), 'ISO-8859-9'
);
});
it('should return ISO-8859-9 (Turkish)', function() {
assert.equal(
chardet.detectFileSync(base + '/iso88599_tr'), 'ISO-8859-9'
);
});
it('should return ISO-8859-10');
it('should return ISO-8859-11');
// iso-8859-12 is abandoned
it('should return ISO-8859-13');
it('should return ISO-8859-14');
it('should return ISO-8859-15');
it('should return ISO-8859-16');
it('should return ISO-8859-10');
it('should return ISO-8859-11');
// iso-8859-12 is abandoned
it('should return ISO-8859-13');
it('should return ISO-8859-14');
it('should return ISO-8859-15');
it('should return ISO-8859-16');
it('should return windows-1250 (Czech)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1250'), 'windows-1250'
);
});
it('should return windows-1250 (Czech)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1250'), 'windows-1250'
);
});
it('should return windows-1251 (Russian)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1251'), 'windows-1251'
);
});
it('should return windows-1251 (Russian)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1251'), 'windows-1251'
);
});
it('should return windows-1252 (English)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1252'), 'windows-1252'
);
});
it('should return windows-1252 (English)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1252'), 'windows-1252'
);
});
it('should return windows-1253 (Greek)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1253'), 'windows-1253'
);
});
it('should return windows-1253 (Greek)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1253'), 'windows-1253'
);
});
it('should return windows-1254 (Turkish)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1254'), 'windows-1254'
);
});
it('should return windows-1254 (Turkish)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1254'), 'windows-1254'
);
});
it('should return windows-1255 (Hebrew)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1255'), 'windows-1255'
);
});
it('should return windows-1255 (Hebrew)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1255'), 'windows-1255'
);
});
it('should return windows-1256 (Arabic)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1256'), 'windows-1256'
);
});
it('should return windows-1256 (Arabic)', function() {
assert.equal(
chardet.detectFileSync(base + '/windows_1256'), 'windows-1256'
);
});
it('should return KOI8-R (Russian)', function() {
assert.equal(
chardet.detectFileSync(base + '/koi8r'), 'KOI8-R'
);
});
it('should return KOI8-R (Russian)', function() {
assert.equal(
chardet.detectFileSync(base + '/koi8r'), 'KOI8-R'
);
});
});
});

View File

@ -1,36 +1,35 @@
var assert = require('assert'),
chardet = require('../../');
chardet = require('../../');
describe('Unicode', function() {
var base = __dirname + '/../data/encodings';
var base = __dirname + '/../data/encodings';
it('should return UTF-16LE', function() {
assert.equal(
chardet.detectFileSync(base + '/utf16le'),
'UTF-16LE'
);
});
it('should return UTF-16LE', function() {
assert.equal(
chardet.detectFileSync(base + '/utf16le'),
'UTF-16LE'
);
});
it('should return UTF-16BE', function() {
assert.equal(
chardet.detectFileSync(base + '/utf16be'),
'UTF-16BE'
);
});
it('should return UTF-16BE', function() {
assert.equal(
chardet.detectFileSync(base + '/utf16be'),
'UTF-16BE'
);
});
it('should return UTF-32LE', function() {
assert.equal(
chardet.detectFileSync(base + '/utf32le'),
'UTF-32LE'
);
});
it('should return UTF-32LE', function() {
assert.equal(
chardet.detectFileSync(base + '/utf32le'),
'UTF-32LE'
);
});
it('should return UTF-32BE', function() {
assert.equal(
chardet.detectFileSync(base + '/utf32be'),
'UTF-32BE'
);
});
});
it('should return UTF-32BE', function() {
assert.equal(
chardet.detectFileSync(base + '/utf32be'),
'UTF-32BE'
);
});
});

View File

@ -1,12 +1,11 @@
var assert = require('assert'),
chardet = require('../../');
chardet = require('../../');
describe('UTF-8', function() {
it('should return UTF-8', function() {
assert.equal(
chardet.detectFileSync(__dirname + '/../data/encodings/utf8'),
'UTF-8'
);
});
});
it('should return UTF-8', function() {
assert.equal(
chardet.detectFileSync(__dirname + '/../data/encodings/utf8'),
'UTF-8'
);
});
});