-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwords-utility-tests.js~
More file actions
59 lines (39 loc) · 1.99 KB
/
words-utility-tests.js~
File metadata and controls
59 lines (39 loc) · 1.99 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
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(), 4.609756097560975);
});
QUnit.test( "find words with the same length", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
var words = wordsUtility.wordsWithTheSameLength();
assert.deepEqual(words,[ "Unit","Test","code","that","your","some","that","work","way.","Unit","from","will","Unit" ])
});
QUnit.test( "no words with the same length return nothing", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
assert.equal(9, wordsUtility.noWordsWithTheSameLength().length);
});
QUnit.test( "find the shortest word", function( assert ) {
var wordsUtility = new WordsUtility(theWords);
assert.equal(wordsUtility.shortestWord(), "A");
});
QUnit.test( "The letter which the most words start with", function( assert ){
var wordsUtility = new WordsUtility(theWords);
assert.equal(wordsUtility.popularLetterStarts(),"t")
});
QUnit.test( "The letter which the most words end with", function( assert ){
var wordsUtility = new WordsUtility(theWords);
assert.equal(wordsUtility.popularLetterEnds(),["s","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