diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-10-07 12:54:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-07 12:54:32 +0000 |
commit | 8eddcc1785a85bbe74be254d1055ebe5125dad10 (patch) | |
tree | f3f51320d12a90a1b421ed8b1f811c576996ea8e /test/shared/settings/Settings.test.ts | |
parent | 7fc2bb615f530fc6adfade54b9553568f5d50ceb (diff) | |
parent | b77a4734985722e96066e713f3b1b9e81a6e1811 (diff) |
Merge pull request #654 from ueokande/settings-as-a-class
Refactor settings on shared logics
Diffstat (limited to 'test/shared/settings/Settings.test.ts')
-rw-r--r-- | test/shared/settings/Settings.test.ts | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/shared/settings/Settings.test.ts b/test/shared/settings/Settings.test.ts new file mode 100644 index 0000000..ab6af04 --- /dev/null +++ b/test/shared/settings/Settings.test.ts @@ -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) + }); + }); +}); |