-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlongestWord.test.ts
28 lines (23 loc) · 938 Bytes
/
longestWord.test.ts
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
import { longestWord } from './longestWord';
describe('#longestWord', () => {
it('should return apple', () => {
const longest = longestWord('abppplee', ['able', 'ale', 'apple', 'bale', 'kangaroo']);
expect(longest).toBe('apple');
});
it('should return able', () => {
const longest = longestWord('abplee', ['able', 'ale', 'apple', 'bale', 'kangaroo']);
expect(longest).toBe('able');
});
it('should return ale', () => {
const longest = longestWord('aflee', ['able', 'ale', 'apple', 'bale', 'kangaroo']);
expect(longest).toBe('ale');
});
it('should return null because the single P', () => {
const longest = longestWord('abplee', ['cable', 'dale', 'apple', 'bale', 'kangaroo']);
expect(longest).toBeNull();
});
it('should return null because no word in dict is subsequence', () => {
const longest = longestWord('bpppleea', ['able', 'ale', 'apple', 'bale', 'kangaroo']);
expect(longest).toBeNull();
});
});