Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from fanerge/master
处理直接使用 String.prototype.length 对码点大于U+010000的字符不正确的问题
- Loading branch information
Showing
4 changed files
with
14,096 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,4 +107,5 @@ describe('string', () => { | |
done(); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.