precis-js
Version:
A JavaScript implementation of RFC 7564 (The PRECIS Framework).
33 lines (23 loc) • 1.27 kB
text/coffeescript
EmptyStringError = require '../../../src/error/EmptyStringError'
precis = require '../../../src/prepare'
UsernameCaseMappedProfile = require '../../../src/profile/UsernameCaseMappedProfile'
describe 'UsernameCaseMappedProfile', ->
beforeEach ->
= new UsernameCaseMappedProfile()
it 'has the correct properties', ->
assert.strictEqual .stringClass, precis.STRING_CLASS.IDENTIFIER
assert.strictEqual .widthMapping, precis.WIDTH_MAPPING.NONE
assert.strictEqual .caseMapping, precis.CASE_MAPPING.LOWERCASE
assert.strictEqual .normalization, precis.NORMALIZATION.C
assert.strictEqual .directionality, precis.DIRECTIONALITY.BIDI
describe 'prePrepareMap()', ->
it 'performs width mapping', ->
actual = [0xFF61, 0xFF67, 0xFFA1, 0xFFDC]
expected = [0x3002, 0x30A1, 0x3131, 0x3163]
.prePrepareMap(actual, precis.preparer)
assert.deepEqual actual, expected
describe 'validate()', ->
it 'allows non-empty strings', ->
assert.doesNotThrow => .validate [0]
it 'rejects empty strings', ->
assert.throws (=> .validate []), EmptyStringError