-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest.js
More file actions
87 lines (67 loc) · 2.43 KB
/
test.js
File metadata and controls
87 lines (67 loc) · 2.43 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import count from './index.mjs';
describe('word count', function() {
function assert(a, b) {
if (a !== b) {
throw new Error(a + ' not equal ' + b);
}
}
it('should count CJK at end', function() {
assert(count('this is 中文'), 4);
});
it('should count CJK at start', function() {
assert(count('中文is this'), 4);
});
it('should count CJK mix', function() {
assert(count('this中文is a 单词'), 7);
});
it('should count Arabic', function() {
assert(count('سلام سلام.'), 2);
});
it('should count Arabic and English', function() {
assert(count('this لغة'), 2);
});
it('should count Arabic 3 words', function() {
assert(count('داد فارسی ۱۲۳۱۲۳'), 3);
});
it('should count Cyrillic and English', function() {
assert(count('this это'), 2);
});
it('should count Cyrillic 3 words', function() {
assert(count('три образца слова'), 3);
});
it('should count contraction as one word', function() {
assert(count('"can\'t"'), 1);
assert(count('James\''),1 );
});
it('should count hyphenated word as one word', function() {
assert(count('well-being'), 1);
});
it('should count mixed languages and contractions', function() {
assert(count('can\'t это لغة'), 3);
});
it('should count mixed languages and hyphenated words', function() {
assert(count('well-being это لغة'), 3);
});
it('should count complex mixed languages, hyphenated words and contractions', function() {
assert(count('我 can\'t believe how fascinating это language fusion is!'), 9);
});
it('should count 0 words for standalone hyphens with spaces', function() {
assert(count('" -- -- -- -- -- -- -- -- -- -- -- -- "'), 0);
});
it('should count 0 words for standalone hyphens without spaces', function() {
assert(count('"- - - - - - - - - - - - - -"'), 0);
});
it('should count German words with umlauts', function() {
assert(count('über'), 1);
assert(count('fräulein'), 1);
assert(count('götterdämmerung'), 1);
});
it('should count mixed languages with German and umlauts', function() {
assert(count('über это لغة'), 3);
assert(count('I can\'t believe the fräulein is singing in 中文'), 10);
assert(count('The götterdämmerung is at dawn'), 5);
});
it('should count Arabic', function() {
assert(count('سلام سلام.'), 2, 'سلام سلام.');
});
});