Skip to content

Commit

Permalink
Merge pull request #111 from fanerge/master
Browse files Browse the repository at this point in the history
处理直接使用 String.prototype.length 对码点大于U+010000的字符不正确的问题
  • Loading branch information
yiminghe committed Jul 18, 2018
2 parents e782748 + 057c404 commit 0722d0d
Show file tree
Hide file tree
Showing 4 changed files with 14,096 additions and 1 deletion.
1 change: 1 addition & 0 deletions __tests__/string.spec.js
Expand Up @@ -107,4 +107,5 @@ describe('string', () => {
done();
});
});

});
47 changes: 47 additions & 0 deletions __tests__/unicode.spec.js
@@ -0,0 +1,47 @@

import Schema from '../src/';

describe('unicode', () => {
it('works for unicode U+0000 to U+FFFF ', (done) => {
new Schema({
v: {
type: 'string',
len: 4
},
}).validate({
v: '吉吉吉吉',
}, (errors) => {
expect(errors).toBe(null);
done();
});
});

it('works for unicode gt U+FFFF ', (done) => {
new Schema({
v: {
type: 'string',
len: 4 // 原来length属性应该为8,更正之后应该为4
},
}).validate({
v: '𠮷𠮷𠮷𠮷',
}, (errors) => {
expect(errors).toBe(null);
done();
});
});

it('Rich Text Format', (done) => {
new Schema({
v: {
type: 'string',
len: 2
},
}).validate({
v: '💩💩',
}, (errors) => {
expect(errors).toBe(null);
done();
});
});

});

0 comments on commit 0722d0d

Please sign in to comment.