-
Notifications
You must be signed in to change notification settings - Fork 0
/
interleave-specs.js
59 lines (50 loc) · 1.62 KB
/
interleave-specs.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
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
/* eslint-env jasmine */
/* eslint-disable no-undef */
describe('interleave', () => {
it('is a function', () => {
expect(typeof interleave).toBe('function');
});
it('interleaves two single-character strings, in the same order they are passed', () => {
const result = interleave('a', 'B');
expect(result).toBe('aB');
});
it('interleaves two strings of equal length', () => {
const result = interleave('hello', 'WORLD');
expect(result).toBe('hWeOlRlLoD');
});
it('does not care about case', () => {
const result = interleave('HELLO', 'world');
expect(result).toBe('HwEoLrLlOd');
});
it('if the first string is longer, it will add the remaining characters to the end', () => {
const result = interleave('thisstringislonger', '123');
expect(result).toBe('t1h2i3sstringislonger');
});
it('if the second string is longer, it will add the remaining characters to the end', () => {
const result = interleave('AFEWLETTERS', 'astringwithmoreletters');
expect(result).toBe('AaFsEtWrLiEnTgTwEiRtShmoreletters');
});
it('interleaves three strings', () => {
const result = interleave('abc', 'XYZ', '123');
expect(result).toBe('aX1bY2cZ3');
});
it('interleaves three longer strings of equal length', () => {
const result = interleave('.......', 'helpful', '-------');
expect(result).toBe('.h-.e-.l-.p-.f-.u-.l-');
});
it('interleaves n strings', () => {
const result = interleave(
'aB',
'cD',
'eF',
'gH',
'iJ',
'kL',
'mN',
'oP',
'qR',
'sT'
);
expect(result).toBe('acegikmoqsBDFHJLNPRT');
});
});