add setting validator

This commit is contained in:
Shin'ya Ueoka 2017-10-01 11:58:34 +09:00
parent 61806a4e7f
commit 2d0968a70b
2 changed files with 58 additions and 0 deletions

View file

@ -0,0 +1,25 @@
import { expect } from "chai";
import { validate } from '../../../src/shared/validators/setting';
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');
});
});
});