-
Notifications
You must be signed in to change notification settings - Fork 327
/
Copy pathch1-q6.spec.js
50 lines (38 loc) · 1.16 KB
/
ch1-q6.spec.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
import * as funcs from './ch1-q6';
import { expect } from 'chai';
for (let key in funcs) {
let func = funcs[key];
describe('ch1-q6: ' + key, function () {
it('returns input where null/undefined', function () {
expect(func(null)).to.be.null;
expect(func(undefined)).to.be.undefined;
});
it('returns input where empty string', function () {
expect(func('')).to.equal('');
});
[
'a',
'aa',
'abc',
'aabbcc',
'ababababccab'
].forEach(arg => {
it(`returns input string where compression doesn't use less space: '${arg}'`, function () {
expect(func(arg)).to.eql(arg);
});
});
[
{ arg: 'aaa', out: 'a3' },
{ arg: 'bbbbbb', out: 'b6' },
{ arg: 'abbbbbbc', out: 'a1b6c1' },
{ arg: 'aaabccc', out: 'a3b1c3' },
{ arg: 'hhellllllllooooo!', out: 'h2e1l8o5!1' },
{ arg: 'woorrrllllddddd', out: 'w1o2r3l4d5' },
{ arg: 'aaaaaaaaaaabbbbbbbbbbbb', out: 'a11b12' }
].forEach(context => {
it(`returns ${context.out} with string ${context.arg}`, function () {
expect(func(context.arg)).to.eql(context.out);
});
});
});
}