Make Settings class
This commit is contained in:
parent
b86b4680b6
commit
0dec6c641f
13 changed files with 120 additions and 99 deletions
54
test/shared/settings/Settings.test.ts
Normal file
54
test/shared/settings/Settings.test.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
import Settings from '../../../src/shared/settings/Settings';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('Settings', () => {
|
||||
describe('#valueOf', () => {
|
||||
it('returns settings by valid settings', () => {
|
||||
let 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', () => {
|
||||
let 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)
|
||||
});
|
||||
});
|
||||
});
|
Reference in a new issue