Skip to content

Commit

Permalink
Merge 31f67b0 into 4a3f5e3
Browse files Browse the repository at this point in the history
  • Loading branch information
wupengFEX committed Jan 16, 2018
2 parents 4a3f5e3 + 31f67b0 commit 7fd25cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mip-validator",
"version": "1.5.12",
"version": "1.5.13",
"description": "MIP validator",
"main": "index.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/encoding/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const jschardet = require('./fake-jschardet.js')
const jschardet = require('jschardet')
const ERR = require('../error/dfn.json')
const allowedEncoding = ['UTF-8', 'ascii']
const logger = require('../logger.js')('mip-validator:encoding')
Expand Down
8 changes: 8 additions & 0 deletions test/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const chai = require('./chai.js')
const expect = chai.expect
const Validator = require('..')
const asciiStr = 'hello'
const ERR = require('../src/error/dfn.json')
const utf8Str = '\xc3\xa0\xc3\xad\xc3\xa0\xc3\xa7\xc3\xa3'
const big5Str = '\xa6\xb8\xb1\x60\xa5\xce\xb0\xea\xa6\x72\xbc\xd0\xb7\xc7\xa6\x72\xc5\xe9\xaa\xed'

describe('encoding', function() {
it('should accept ASCII', function() {
Expand All @@ -15,4 +17,10 @@ describe('encoding', function() {
var result = validator.validate(utf8Str)
expect(result).to.have.lengthOf(0)
})
it('should reject Big5', function () {
var validator = Validator({})
var result = validator.validate(big5Str)
expect(result).to.have.lengthOf(1)
expect(result[0].code).to.equal(ERR.DISALLOWED_ENCODING.code)
})
})

0 comments on commit 7fd25cd

Please sign in to comment.