-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfn-spec.js
More file actions
71 lines (52 loc) · 2.48 KB
/
Copy pathfn-spec.js
File metadata and controls
71 lines (52 loc) · 2.48 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
var frequencyNumber = require('./fn.js')
/*describe('split String to words', function(){
it('return null given null', function(){
expect(frequencyNumber.splitString('')).toEqual('');
});
it('return one word given one word ', function(){
expect(frequencyNumber.splitString('it')).toEqual(['it']);
});
it('return two word given two word', function(){
expect(frequencyNumber.splitString('it will')).toEqual(['it','will']);
});
it('return three word given three word ', function(){
expect(frequencyNumber.splitString('it will get')).toEqual(['it', 'will', 'get']);
});
it('return two word given two word with some blanks', function(){
expect(frequencyNumber.splitString(' it will ')).toEqual(['it','will']);
});
}
);
describe('count the Frequency of words',function () {
it ('return one word and its frequency given one word', function () {
expect(frequencyNumber.countFreqy(['it'])).toEqual("it 1");
});
it ('return two word and their own frequency given two different word', function () {
expect(frequencyNumber.countFreqy(['it','is'])).toEqual("it 1\r\nis 1");
});
it ('return one word and their own frequency given two same word', function () {
expect(frequencyNumber.countFreqy(['it','it'])).toEqual("it 2");
});
});
describe ('sort the Frequency of the words',function(){
it('return the result in sequence given the random result',function(){
expect(frequencyNumber.sortFrequency([{word: 'it',count : 2},{word:'will',count:1}])).toEqual("will 1\r\nit 2");
});
it('return the result in sequence given the random result',function(){
expect(frequencyNumber.sortFrequency([{word: 'it',count : 3},{word:'will',count:2},{word:'is', count: 1}])).toEqual("is 1\r\nwill 2\r\nit 3");
});
});*/
describe('test for main',function(){
it('return the result given the string ',function(){
expect(frequencyNumber.main('it')).toEqual('it 1');
});
it('return the result given the string ',function(){
expect(frequencyNumber.main('it will')).toEqual('it 1\r\nwill 1');
});
it('return the result given the string ',function(){
expect(frequencyNumber.main('it will be it ')).toEqual('will 1\r\nbe 1\r\nit 2');
});
it('return the result given the string ',function(){
expect(frequencyNumber.main(' it will it ')).toEqual('will 1\r\nit 2');
});
});