-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
66 lines (54 loc) · 2.6 KB
/
test.js
File metadata and controls
66 lines (54 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
describe('Testing ascii-fullwidth-haflwidth-convert', () => {
const Converter = require('.');
const afhc = new Converter();
const HALF_WIDTH =
'!"#$%&\'()*+,-./0123456789:;<=>?' +
'@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_' +
'`abcdefghijklmnopqrstuvwxyz{|}~' +
'\u0020';
const FULL_WIDTH =
'!"#$%&'()*+,-./' +
'0123456789:;<=>?' +
'@ABCDEFGHIJKLMNO' +
'PQRSTUVWXYZ[\]^_' +
'`abcdefghijklmno' +
'pqrstuvwxyz{|}~' +
'\u3000';
const NUM_CODE_POINTS = HALF_WIDTH.length;
const MIXED = 'THE quick, BROWN\u3000fox.';
const MIXED_TO_FULL = 'THE\u3000quick,\u3000BROWN\u3000fox.';
const MIXED_TO_HALF = 'THE quick, BROWN fox.';
describe('Testing toFullWidth', () => {
for (let i = 0; i < NUM_CODE_POINTS; i++) {
let halfWidthChar = HALF_WIDTH[i];
let fullWidthChar = FULL_WIDTH[i];
it ('Should convert ' + halfWidthChar + ' to ' + fullWidthChar + '.', () => {
afhc.toFullWidth(halfWidthChar).should.be.exactly(fullWidthChar);
});
}
it('Should convert the half-width characters to full-width characters.', () => {
afhc.toFullWidth(HALF_WIDTH).should.be.exactly(FULL_WIDTH);
});
it('Should convert mixed string to full width', () => {
afhc.toFullWidth(MIXED).should.be.exactly(MIXED_TO_FULL);
});
});
it('Should convert the half-width characters to full-width characters.', () => {
afhc.toHalfWidth(FULL_WIDTH).should.be.exactly(HALF_WIDTH);
});
describe('Testing toHalfWidth', () => {
for (let i = 0; i < NUM_CODE_POINTS; i++) {
let halfWidthChar = HALF_WIDTH[i];
let fullWidthChar = FULL_WIDTH[i];
it ('Should convert ' + fullWidthChar + ' to ' + halfWidthChar + '.', () => {
afhc.toHalfWidth(fullWidthChar).should.be.exactly(halfWidthChar);
});
}
it('Should convert the full-width characters to half-width characters.', () => {
afhc.toHalfWidth(FULL_WIDTH).should.be.exactly(HALF_WIDTH);
});
it('Should convert mixed string to half width', () => {
afhc.toHalfWidth(MIXED).should.be.exactly(MIXED_TO_HALF);
});
});
});