-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathword-count.spec.js
More file actions
65 lines (52 loc) · 2.37 KB
/
Copy pathword-count.spec.js
File metadata and controls
65 lines (52 loc) · 2.37 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
var Words = require('./word-count');
describe('count()', function() {
var words = new Words();
it('counts one word', function() {
var expectedCounts = { word: 1 };
expect(words.count('word')).toEqual(expectedCounts);
});
xit('counts one of each', function() {
var expectedCounts = { one: 1, of: 1, each: 1 };
expect(words.count('one of each')).toEqual(expectedCounts);
});
xit('counts multiple occurrences', function() {
var expectedCounts = { one: 1, fish: 4, two: 1, red: 1, blue: 1 };
expect(words.count('one fish two fish red fish blue fish')).toEqual(expectedCounts);
});
xit('includes punctuation', function() {
var expectedCounts = { car: 1, ':': 2, carpet: 1, as: 1, java: 1, 'javascript!!&@$%^&': 1 };
expect(words.count('car : carpet as java : javascript!!&@$%^&')).toEqual(expectedCounts);
});
xit('includes numbers', function() {
var expectedCounts = { testing: 2, 1: 1, 2: 1 };
expect(words.count('testing 1 2 testing')).toEqual(expectedCounts);
});
xit('normalizes to lowercase', function() {
var expectedCounts = { go: 3 };
expect(words.count('go Go GO')).toEqual(expectedCounts);
});
xit('counts properly international characters', function() {
var expectedCounts = { '¡hola!': 1, '¿qué': 1, 'tal?': 1, 'привет!': 1 };
expect(words.count('¡Hola! ¿Qué tal? Привет!')).toEqual(expectedCounts);
});
xit('counts multiline', function() {
var expectedCounts = { hello: 1, world: 1 };
expect(words.count('hello\nworld')).toEqual(expectedCounts);
});
xit('counts tabs', function() {
var expectedCounts = { hello: 1, world: 1 };
expect(words.count('hello\tworld')).toEqual(expectedCounts);
});
xit('counts multiple spaces as one', function() {
var expectedCounts = { hello: 1, world: 1 };
expect(words.count('hello world')).toEqual(expectedCounts);
});
xit('does not count leading or trailing whitespace', function() {
var expectedCounts = { introductory: 1, course: 1 };
expect(words.count('\t\tIntroductory Course ')).toEqual(expectedCounts);
});
xit('handles properties that exist on Object’s prototype', function() {
var expectedCounts = { reserved: 1, words: 1, like: 1, constructor: 1, and: 1, tostring: 1, 'ok?': 1 };
expect(words.count('reserved words like constructor and toString ok?')).toEqual(expectedCounts);
});
});