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
|
import Settings from '../../../src/shared/settings/Settings';
import { expect } from 'chai';
describe('Settings', () => {
describe('#valueOf', () => {
it('returns settings by valid settings', () => {
const x = Settings.fromJSON({
keymaps: {},
"search": {
"default": "google",
"engines": {
"google": "https://google.com/search?q={}",
}
},
"properties": {},
"blacklist": []
});
expect({
keymaps: x.keymaps.toJSON(),
search: x.search.toJSON(),
properties: x.properties.toJSON(),
blacklist: x.blacklist.toJSON(),
}).to.deep.equal({
keymaps: {},
search: {
default: "google",
engines: {
google: "https://google.com/search?q={}",
}
},
properties: {
hintchars: "abcdefghijklmnopqrstuvwxyz",
smoothscroll: false,
complete: "sbh"
},
blacklist: []
});
});
it('sets default settings', () => {
const value = Settings.fromJSON({});
expect(value.keymaps.toJSON()).to.not.be.empty;
expect(value.properties.toJSON()).to.not.be.empty;
expect(value.search.defaultEngine).to.be.a('string');
expect(value.search.engines).to.be.an('object');
expect(value.blacklist.toJSON()).to.be.empty;
});
it('throws a TypeError with an unknown field', () => {
expect(() => Settings.fromJSON({ name: 'alice' })).to.throw(TypeError)
});
});
});
|