2013-04-30 13:49:02 +00:00
|
|
|
var assert = require('assert'),
|
2013-11-22 04:40:19 +00:00
|
|
|
chardet = require('../'),
|
|
|
|
fs = require('fs');
|
2013-04-30 13:49:02 +00:00
|
|
|
|
|
|
|
describe('chardet', function() {
|
|
|
|
|
2013-11-22 04:40:19 +00:00
|
|
|
var path = __dirname + '/data/encodings/utf8';
|
2013-04-30 13:49:02 +00:00
|
|
|
|
2013-11-22 04:40:19 +00:00
|
|
|
describe('#detect', function() {
|
|
|
|
it('should detect encoding', function() {
|
|
|
|
assert.equal(chardet.detect(fs.readFileSync(path)), 'UTF-8');
|
2013-04-30 13:49:02 +00:00
|
|
|
});
|
2013-11-22 04:40:19 +00:00
|
|
|
});
|
2013-04-30 13:49:02 +00:00
|
|
|
|
2013-11-22 04:40:19 +00:00
|
|
|
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();
|
|
|
|
});
|
2013-04-30 13:49:02 +00:00
|
|
|
});
|
2013-11-22 04:40:19 +00:00
|
|
|
});
|
2013-04-30 13:49:02 +00:00
|
|
|
|
2013-11-22 04:40:19 +00:00
|
|
|
describe('#detectFileSync', function() {
|
|
|
|
it('should detect encoding', function() {
|
|
|
|
assert.equal(chardet.detectFileSync(path), 'UTF-8');
|
2013-04-30 13:49:02 +00:00
|
|
|
});
|
2013-11-22 04:40:19 +00:00
|
|
|
});
|
|
|
|
});
|