-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.test.js
32 lines (25 loc) · 1.12 KB
/
example.test.js
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
const mostCommonWord = require('./example')
test('mostCommonWord returns only word', () => {
const result = mostCommonWord(["hello"])
expect(result).toBe("hello");
});
test('mostCommonWord returns only word when there are two', () => {
const result = mostCommonWord(["hello", "hello"])
expect(result).toBe("hello");
});
test('mostCommonWord is hello when there are two hellos and one other word', () => {
const result = mostCommonWord(["hello", "hello", "other"])
expect(result).toBe("hello");
});
test('mostCommonWord is hello when there are two hellos and one other word', () => {
const result = mostCommonWord(["other", "hello", "hello"])
expect(result).toBe("hello");
});
test('mostCommonWord is something when there are lots of duplicates', () => {
const result = mostCommonWord(["other", "something", "hello", "hello", "other", "something", "something"])
expect(result).toBe("something");
});
test('mostCommonWord when there is a tie, should return the first one from the list', () => {
const result = mostCommonWord(["other", "hello", "hello", "other"])
expect(result).toBe("other")
})