-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwords-utility-tests.js
More file actions
127 lines (104 loc) · 2.58 KB
/
words-utility-tests.js
File metadata and controls
127 lines (104 loc) · 2.58 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
var theWords = "A Unit Test is a piece of code that is using your code, exercising some scenarios that it expects to work in a certain way. Unit tests are isolated from external dependencies unlike integration tests. We will focus on Unit Tests.";
QUnit.test( "test if words are counted correctly", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
assert.equal(wordsUtility.countWords(), 41);
});
QUnit.test( "find the longest word", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
assert.equal(wordsUtility.longestWord(), "dependencies");
});
QUnit.test( "the average word length of words supplied", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
assert.equal(wordsUtility.averageWordLength(), " 5.585365853658536");
});
QUnit.test( "find words with the same length", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
var words = wordsUtility.wordsWithTheSameLength();
assert.deepEqual(wordsUtility.wordsWithTheSameLength(), { "1": [
"a",
"a",
"a"
],
"10": [
"exercising"
],
"11": [
"integration"
],
"12": [
"dependencies"
],
"2": [
"is",
"of",
"is",
"it",
"to",
"in",
"we",
"on"
],
"3": [
"are"
],
"4": [
"unit",
"test",
"code",
"that",
"your",
"some",
"that",
"work",
"way.",
"unit",
"from",
"will",
"unit"
],
"5": [
"piece",
"using",
"code,",
"tests",
"focus"
],
"6": [
"unlike",
"tests.",
"tests."
],
"7": [
"expects",
"certain"
],
"8": [
"isolated",
"external"
],
"9": [
"scenarios"
]
})
});
QUnit.test( "no words with the same length return nothing", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
assert.equal(undefined, wordsUtility.wordsWithTheSameLength().length, 5);
});
QUnit.test( "find the shortest word", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
assert.equal(wordsUtility.shortestWord(), "A");
});
QUnit.test( "most words end with", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
assert.equal(wordsUtility.mostWordsEndWith(), "s");
});
QUnit.test( "most words start with", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
assert.equal(wordsUtility.mostWordsStartWith(), "t");
});
QUnit.jUnitReport = function(report) {
console.log(report.xml);
};
//create a test for What letter does the most words start with
//create a test for What letter does the most words end with