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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
import { expect } from "chai";
import { validate } from 'shared/settings/validator';
describe("setting validator", () => {
describe("unknown top keys", () => {
it('throws an error for unknown settings', () => {
let settings = { keymaps: {}, poison: 123 };
let fn = validate.bind(undefined, settings)
expect(fn).to.throw(Error, 'poison');
})
});
describe("keymaps settings", () => {
it('throws an error for unknown operation', () => {
let settings = {
keymaps: {
a: { 'type': 'scroll.home' },
b: { 'type': 'poison.dressing' },
}
};
let fn = validate.bind(undefined, settings)
expect(fn).to.throw(Error, 'poison.dressing');
});
});
describe("search settings", () => {
it('throws an error for invalid search engine name', () => {
let settings = {
search: {
default: 'google',
engines: {
'google': 'https://google.com/search?q={}',
'cherry pie': 'https://cherypie.com/search?q={}',
}
}
};
let fn = validate.bind(undefined, settings)
expect(fn).to.throw(Error, 'cherry pie');
});
it('throws an error for no {}-placeholder', () => {
let settings = {
search: {
default: 'google',
engines: {
'google': 'https://google.com/search?q={}',
'yahoo': 'https://search.yahoo.com/search',
}
}
};
let fn = validate.bind(undefined, settings)
expect(fn).to.throw(Error, 'yahoo');
});
it('throws an error for no default engines', () => {
let settings = {
search: {
engines: {
'google': 'https://google.com/search?q={}',
'yahoo': 'https://search.yahoo.com/search?q={}',
}
}
};
let fn = validate.bind(undefined, settings)
expect(fn).to.throw(Error, 'Default engine');
});
it('throws an error for invalid default engine', () => {
let settings = {
search: {
default: 'twitter',
engines: {
'google': 'https://google.com/search?q={}',
'yahoo': 'https://search.yahoo.com/search?q={}',
}
}
};
let fn = validate.bind(undefined, settings)
expect(fn).to.throw(Error, 'twitter');
});
});
});
|