aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/content/repositories/SettingRepository.test.ts13
-rw-r--r--test/content/usecases/SettingUseCaase.test.ts2
-rw-r--r--test/shared/SettingData.test.ts39
-rw-r--r--test/shared/settings/Settings.test.ts (renamed from test/shared/Settings.test.ts)10
4 files changed, 30 insertions, 34 deletions
diff --git a/test/content/repositories/SettingRepository.test.ts b/test/content/repositories/SettingRepository.test.ts
index 363fcec..db4c528 100644
--- a/test/content/repositories/SettingRepository.test.ts
+++ b/test/content/repositories/SettingRepository.test.ts
@@ -1,27 +1,26 @@
import { SettingRepositoryImpl } from '../../../src/content/repositories/SettingRepository';
import { expect } from 'chai';
-import Keymaps from '../../../src/shared/settings/Keymaps';
-import Search from '../../../src/shared/settings/Search';
+import Settings from '../../../src/shared/settings/Settings';
describe('SettingRepositoryImpl', () => {
it('updates and gets current value', () => {
let sut = new SettingRepositoryImpl();
- let settings = {
- keymaps: Keymaps.fromJSON({}),
- search: Search.fromJSON({
+ let settings = Settings.fromJSON({
+ keymaps: {},
+ search:{
default: 'google',
engines: {
google: 'https://google.com/?q={}',
}
- }),
+ },
properties: {
hintchars: 'abcd1234',
smoothscroll: false,
complete: 'sbh',
},
blacklist: [],
- };
+ });
sut.set(settings);
diff --git a/test/content/usecases/SettingUseCaase.test.ts b/test/content/usecases/SettingUseCaase.test.ts
index e9633f4..136c5af 100644
--- a/test/content/usecases/SettingUseCaase.test.ts
+++ b/test/content/usecases/SettingUseCaase.test.ts
@@ -1,7 +1,7 @@
import SettingRepository from '../../../src/content/repositories/SettingRepository';
import SettingClient from '../../../src/content/client/SettingClient';
import SettingUseCase from '../../../src/content/usecases/SettingUseCase';
-import Settings, { DefaultSetting } from '../../../src/shared/Settings';
+import Settings, { DefaultSetting } from '../../../src/shared/settings/Settings';
import { expect } from 'chai';
class MockSettingRepository implements SettingRepository {
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)
});
});
});