diff options
Diffstat (limited to 'test/shared')
-rw-r--r-- | test/shared/SettingData.test.ts | 39 | ||||
-rw-r--r-- | test/shared/settings/Settings.test.ts (renamed from test/shared/Settings.test.ts) | 10 |
2 files changed, 23 insertions, 26 deletions
diff --git a/test/shared/SettingData.test.ts b/test/shared/SettingData.test.ts index 4391e73..138d768 100644 --- a/test/shared/SettingData.test.ts +++ b/test/shared/SettingData.test.ts @@ -1,12 +1,9 @@ import SettingData, { FormKeymaps, JSONTextSettings, FormSettings, } from '../../src/shared/SettingData'; -import Settings from '../../src/shared/Settings'; +import Settings from '../../src/shared/settings/Settings'; import { expect } from 'chai'; import Keymaps from '../../src/shared/settings/Keymaps'; -import Search from '../../src/shared/settings/Search'; -import Properties from '../../src/shared/settings/Properties'; -import Blacklist from '../../src/shared/settings/Blacklist' describe('shared/SettingData', () => { describe('FormKeymaps', () => { @@ -72,21 +69,21 @@ describe('shared/SettingData', () => { describe('#fromSettings to #toJSON', () => { it('create from a Settings and create a JSON string', () => { - let o = { - keymaps: Keymaps.fromJSON({}), - search: Search.fromJSON({ + let o = Settings.fromJSON({ + keymaps: {}, + search: { default: "google", engines: { google: "https://google.com/search?q={}", }, - }), - properties: Properties.fromJSON({ + }, + properties: { hintchars: "abcdefghijklmnopqrstuvwxyz", smoothscroll: false, complete: "sbh" - }), - blacklist: Blacklist.fromJSON([]), - }; + }, + blacklist: [], + }); let json = JSONTextSettings.fromSettings(o).toJSONText(); expect(JSON.parse(json)).to.deep.equal({ @@ -150,24 +147,24 @@ describe('shared/SettingData', () => { describe('#fromSettings to #toJSON', () => { it('create from a Settings and create a JSON string', () => { - let data: Settings = { - keymaps: Keymaps.fromJSON({ + let data: Settings = Settings.fromJSON({ + keymaps: { 'j': { type: 'scroll.vertically', count: 1 }, '0': { type: 'scroll.home' }, - }), - search: Search.fromJSON({ + }, + search: { default: "google", engines: { "google": "https://google.com/search?q={}" } - }), - properties: Properties.fromJSON({ + }, + properties: { hintchars: "abcdefghijklmnopqrstuvwxyz", smoothscroll: false, complete: "sbh" - }), - blacklist: Blacklist.fromJSON([]), - }; + }, + blacklist: [], + }); let json = FormSettings.fromSettings(data).toJSON(); expect(json).to.deep.equal({ diff --git a/test/shared/Settings.test.ts b/test/shared/settings/Settings.test.ts index 9688798..ab6af04 100644 --- a/test/shared/Settings.test.ts +++ b/test/shared/settings/Settings.test.ts @@ -1,10 +1,10 @@ -import * as settings from '../../src/shared/Settings'; -import {expect} from 'chai'; +import Settings from '../../../src/shared/settings/Settings'; +import { expect } from 'chai'; describe('Settings', () => { describe('#valueOf', () => { it('returns settings by valid settings', () => { - let x = settings.valueOf({ + let x = Settings.fromJSON({ keymaps: {}, "search": { "default": "google", @@ -39,7 +39,7 @@ describe('Settings', () => { }); it('sets default settings', () => { - let value = settings.valueOf({}); + 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'); @@ -48,7 +48,7 @@ describe('Settings', () => { }); it('throws a TypeError with an unknown field', () => { - expect(() => settings.valueOf({ name: 'alice' })).to.throw(TypeError) + expect(() => Settings.fromJSON({ name: 'alice' })).to.throw(TypeError) }); }); }); |