Make Properties class
This commit is contained in:
parent
2116ac90a6
commit
574692551a
16 changed files with 179 additions and 236 deletions
|
@ -13,14 +13,14 @@ describe("settings/form/PropertiesForm", () => {
|
|||
mybool: 'boolean',
|
||||
empty: 'string',
|
||||
}
|
||||
let value = {
|
||||
let values = {
|
||||
mystr: 'abc',
|
||||
mynum: 123,
|
||||
mybool: true,
|
||||
};
|
||||
|
||||
let root = ReactTestRenderer.create(
|
||||
<PropertiesForm types={types} value={value} />,
|
||||
<PropertiesForm types={types} value={values} />,
|
||||
).root
|
||||
|
||||
let input = root.findByProps({ name: 'mystr' });
|
||||
|
|
|
@ -5,6 +5,7 @@ import Settings from '../../src/shared/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';
|
||||
|
||||
describe('shared/SettingData', () => {
|
||||
describe('FormKeymaps', () => {
|
||||
|
@ -62,7 +63,7 @@ describe('shared/SettingData', () => {
|
|||
expect({
|
||||
keymaps: settings.keymaps.toJSON(),
|
||||
search: settings.search.toJSON(),
|
||||
properties: settings.properties,
|
||||
properties: settings.properties.toJSON(),
|
||||
blacklist: settings.blacklist,
|
||||
}).to.deep.equal(JSON.parse(o));
|
||||
});
|
||||
|
@ -78,11 +79,11 @@ describe('shared/SettingData', () => {
|
|||
google: "https://google.com/search?q={}",
|
||||
},
|
||||
}),
|
||||
properties: {
|
||||
properties: Properties.fromJSON({
|
||||
hintchars: "abcdefghijklmnopqrstuvwxyz",
|
||||
smoothscroll: false,
|
||||
complete: "sbh"
|
||||
},
|
||||
}),
|
||||
blacklist: [],
|
||||
};
|
||||
|
||||
|
@ -90,7 +91,7 @@ describe('shared/SettingData', () => {
|
|||
expect(JSON.parse(json)).to.deep.equal({
|
||||
keymaps: o.keymaps.toJSON(),
|
||||
search: o.search.toJSON(),
|
||||
properties: o.properties,
|
||||
properties: o.properties.toJSON(),
|
||||
blacklist: o.blacklist,
|
||||
});
|
||||
});
|
||||
|
@ -123,7 +124,7 @@ describe('shared/SettingData', () => {
|
|||
expect({
|
||||
keymaps: settings.keymaps.toJSON(),
|
||||
search: settings.search.toJSON(),
|
||||
properties: settings.properties,
|
||||
properties: settings.properties.toJSON(),
|
||||
blacklist: settings.blacklist,
|
||||
}).to.deep.equal({
|
||||
keymaps: {
|
||||
|
@ -159,11 +160,11 @@ describe('shared/SettingData', () => {
|
|||
"google": "https://google.com/search?q={}"
|
||||
}
|
||||
}),
|
||||
properties: {
|
||||
properties: Properties.fromJSON({
|
||||
hintchars: "abcdefghijklmnopqrstuvwxyz",
|
||||
smoothscroll: false,
|
||||
complete: "sbh"
|
||||
},
|
||||
}),
|
||||
blacklist: []
|
||||
};
|
||||
|
||||
|
|
|
@ -1,33 +1,8 @@
|
|||
import * as settings from '../../src/shared/Settings';
|
||||
import { expect } from 'chai';
|
||||
import {expect} from 'chai';
|
||||
|
||||
describe('Settings', () => {
|
||||
|
||||
describe('#propertiesValueOf', () => {
|
||||
it('returns with default properties by empty settings', () => {
|
||||
let props = settings.propertiesValueOf({});
|
||||
expect(props).to.deep.equal({
|
||||
hintchars: "abcdefghijklmnopqrstuvwxyz",
|
||||
smoothscroll: false,
|
||||
complete: "sbh"
|
||||
})
|
||||
});
|
||||
|
||||
it('returns properties by valid settings', () => {
|
||||
let props = settings.propertiesValueOf({
|
||||
hintchars: "abcdefgh",
|
||||
smoothscroll: false,
|
||||
complete: "sbh"
|
||||
});
|
||||
|
||||
expect(props).to.deep.equal({
|
||||
hintchars: "abcdefgh",
|
||||
smoothscroll: false,
|
||||
complete: "sbh"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#blacklistValueOf', () => {
|
||||
it('returns empty array by empty settings', () => {
|
||||
let blacklist = settings.blacklistValueOf([]);
|
||||
|
@ -70,7 +45,7 @@ describe('Settings', () => {
|
|||
expect({
|
||||
keymaps: x.keymaps.toJSON(),
|
||||
search: x.search.toJSON(),
|
||||
properties: x.properties,
|
||||
properties: x.properties.toJSON(),
|
||||
blacklist: x.blacklist,
|
||||
}).to.deep.equal({
|
||||
keymaps: {},
|
||||
|
@ -92,7 +67,7 @@ describe('Settings', () => {
|
|||
it('sets default settings', () => {
|
||||
let value = settings.valueOf({});
|
||||
expect(value.keymaps.toJSON()).to.not.be.empty;
|
||||
expect(value.properties).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).to.be.empty;
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
import * as settings from 'shared/settings';
|
||||
|
||||
describe('properties', () => {
|
||||
describe('Def class', () => {
|
||||
it('returns property definitions', () => {
|
||||
let def = new proerties.Def(
|
||||
'smoothscroll',
|
||||
'smooth scroll',
|
||||
false);
|
||||
|
||||
expect(def.name).to.equal('smoothscroll');
|
||||
expect(def.describe).to.equal('smooth scroll');
|
||||
expect(def.defaultValue).to.equal(false);
|
||||
expect(def.type).to.equal('boolean');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
import * as settings from 'shared/settings';
|
||||
|
||||
describe('properties', () => {
|
||||
describe('Def class', () => {
|
||||
it('returns property definitions', () => {
|
||||
let def = new proerties.Def(
|
||||
'smoothscroll',
|
||||
'smooth scroll',
|
||||
false);
|
||||
|
||||
expect(def.name).to.equal('smoothscroll');
|
||||
expect(def.describe).to.equal('smooth scroll');
|
||||
expect(def.defaultValue).to.equal(false);
|
||||
expect(def.type).to.equal('boolean');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
30
test/shared/settings/Properties.test.ts
Normal file
30
test/shared/settings/Properties.test.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import Properties from '../../../src/shared/settings/Properties';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('Properties', () => {
|
||||
describe('#propertiesValueOf', () => {
|
||||
it('returns with default properties by empty settings', () => {
|
||||
let props = Properties.fromJSON({});
|
||||
expect(props).to.deep.equal({
|
||||
hintchars: "abcdefghijklmnopqrstuvwxyz",
|
||||
smoothscroll: false,
|
||||
complete: "sbh"
|
||||
})
|
||||
});
|
||||
|
||||
it('returns properties by valid settings', () => {
|
||||
let props = Properties.fromJSON({
|
||||
hintchars: "abcdefgh",
|
||||
smoothscroll: false,
|
||||
complete: "sbh"
|
||||
});
|
||||
|
||||
expect(props).to.deep.equal({
|
||||
hintchars: "abcdefgh",
|
||||
smoothscroll: false,
|
||||
complete: "sbh"
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in a new issue