diff options
Diffstat (limited to 'test/settings')
-rw-r--r-- | test/settings/components/form/BlacklistForm.test.tsx | 20 | ||||
-rw-r--r-- | test/settings/components/form/KeymapsForm.test.tsx | 14 | ||||
-rw-r--r-- | test/settings/components/form/PropertiesForm.test.tsx | 12 | ||||
-rw-r--r-- | test/settings/components/form/SearchEngineForm.test.tsx | 20 | ||||
-rw-r--r-- | test/settings/components/ui/input.test.tsx | 20 | ||||
-rw-r--r-- | test/settings/reducers/setting.test.ts | 18 |
6 files changed, 52 insertions, 52 deletions
diff --git a/test/settings/components/form/BlacklistForm.test.tsx b/test/settings/components/form/BlacklistForm.test.tsx index 7daf513..6c329ff 100644 --- a/test/settings/components/form/BlacklistForm.test.tsx +++ b/test/settings/components/form/BlacklistForm.test.tsx @@ -10,11 +10,11 @@ import Blacklist from '../../../../src/shared/settings/Blacklist'; describe("settings/form/BlacklistForm", () => { describe('render', () => { it('renders BlacklistForm', () => { - let root = ReactTestRenderer.create( + const root = ReactTestRenderer.create( <BlacklistForm value={Blacklist.fromJSON(['*.slack.com', 'www.google.com/maps'])} />, ).root; - let children = root.children[0].children; + const children = root.children[0].children; expect(children).to.have.lengthOf(3); expect(children[0].children[0].props.value).to.equal('*.slack.com'); expect(children[1].children[0].props.value).to.equal('www.google.com/maps'); @@ -22,9 +22,9 @@ describe("settings/form/BlacklistForm", () => { }); it('renders blank value', () => { - let root = ReactTestRenderer.create(<BlacklistForm />).root; + const root = ReactTestRenderer.create(<BlacklistForm />).root; - let children = root.children[0].children; + const children = root.children[0].children; expect(children).to.have.lengthOf(1); expect(children[0].props.name).to.equal('add'); }); @@ -48,14 +48,14 @@ describe("settings/form/BlacklistForm", () => { ReactDOM.render(<BlacklistForm value={Blacklist.fromJSON(['*.slack.com', 'www.google.com/maps*'])} onChange={value => { - let urls = value.items.map(item => item.pattern); + const urls = value.items.map(item => item.pattern); expect(urls).to.have.members(['gitter.im', 'www.google.com/maps*']); done(); }} />, container) }); - let input = document.querySelectorAll('input[type=text]')[0]; + const input = document.querySelectorAll('input[type=text]')[0]; input.value = 'gitter.im'; ReactTestUtils.Simulate.change(input); }); @@ -65,14 +65,14 @@ describe("settings/form/BlacklistForm", () => { ReactDOM.render(<BlacklistForm value={Blacklist.fromJSON(['*.slack.com', 'www.google.com/maps*'])} onChange={value => { - let urls = value.items.map(item => item.pattern); + const urls = value.items.map(item => item.pattern); expect(urls).to.have.members(['www.google.com/maps*']); done(); }} />, container) }); - let button = document.querySelectorAll('input[type=button]')[0]; + const button = document.querySelectorAll('input[type=button]')[0]; ReactTestUtils.Simulate.click(button); }); @@ -81,14 +81,14 @@ describe("settings/form/BlacklistForm", () => { ReactDOM.render(<BlacklistForm value={Blacklist.fromJSON(['*.slack.com'])} onChange={value => { - let urls = value.items.map(item => item.pattern); + const urls = value.items.map(item => item.pattern); expect(urls).to.have.members(['*.slack.com', '']); done(); }} />, container); }); - let button = document.querySelector('input[type=button].ui-add-button'); + const button = document.querySelector('input[type=button].ui-add-button'); ReactTestUtils.Simulate.click(button); }); }); diff --git a/test/settings/components/form/KeymapsForm.test.tsx b/test/settings/components/form/KeymapsForm.test.tsx index 1d1e77c..ccc772c 100644 --- a/test/settings/components/form/KeymapsForm.test.tsx +++ b/test/settings/components/form/KeymapsForm.test.tsx @@ -9,23 +9,23 @@ import { expect } from 'chai'; describe("settings/form/KeymapsForm", () => { describe('render', () => { it('renders keymap fields', () => { - let root = ReactTestRenderer.create(<KeymapsForm value={FormKeymaps.fromJSON({ + const root = ReactTestRenderer.create(<KeymapsForm value={FormKeymaps.fromJSON({ 'scroll.vertically?{"count":1}': 'j', 'scroll.vertically?{"count":-1}': 'k', })} />).root - let inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); - let inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); + const inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); + const inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); expect(inputj.props.value).to.equal('j'); expect(inputk.props.value).to.equal('k'); }); it('renders blank value', () => { - let root = ReactTestRenderer.create(<KeymapsForm />).root; + const root = ReactTestRenderer.create(<KeymapsForm />).root; - let inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); - let inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); + const inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); + const inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); expect(inputj.props.value).to.be.empty; expect(inputk.props.value).to.be.empty; @@ -58,7 +58,7 @@ describe("settings/form/KeymapsForm", () => { }} />, container); }); - let input = document.getElementById('scroll.vertically?{"count":1}'); + const input = document.getElementById('scroll.vertically?{"count":1}'); input.value = 'jjj'; ReactTestUtils.Simulate.change(input); }); diff --git a/test/settings/components/form/PropertiesForm.test.tsx b/test/settings/components/form/PropertiesForm.test.tsx index 0e33cc8..4a0e25a 100644 --- a/test/settings/components/form/PropertiesForm.test.tsx +++ b/test/settings/components/form/PropertiesForm.test.tsx @@ -7,19 +7,19 @@ import PropertiesForm from 'settings/components/form/PropertiesForm' describe("settings/form/PropertiesForm", () => { describe('render', () => { it('renders PropertiesForm', () => { - let types = { + const types = { mystr: 'string', mynum: 'number', mybool: 'boolean', empty: 'string', } - let values = { + const values = { mystr: 'abc', mynum: 123, mybool: true, }; - let root = ReactTestRenderer.create( + const root = ReactTestRenderer.create( <PropertiesForm types={types} value={values} />, ).root @@ -62,7 +62,7 @@ describe("settings/form/PropertiesForm", () => { />, container); }); - let input = document.querySelector('input[name=myvalue]'); + const input = document.querySelector('input[name=myvalue]'); input.value = 'abcd' ReactTestUtils.Simulate.change(input); }); @@ -79,7 +79,7 @@ describe("settings/form/PropertiesForm", () => { />, container); }); - let input = document.querySelector('input[name=myvalue]'); + const input = document.querySelector('input[name=myvalue]'); input.value = '1234' ReactTestUtils.Simulate.change(input); }); @@ -96,7 +96,7 @@ describe("settings/form/PropertiesForm", () => { />, container); }); - let input = document.querySelector('input[name=myvalue]'); + const input = document.querySelector('input[name=myvalue]'); input.checked = true; ReactTestUtils.Simulate.change(input); }); diff --git a/test/settings/components/form/SearchEngineForm.test.tsx b/test/settings/components/form/SearchEngineForm.test.tsx index 1f0420d..b918203 100644 --- a/test/settings/components/form/SearchEngineForm.test.tsx +++ b/test/settings/components/form/SearchEngineForm.test.tsx @@ -8,17 +8,17 @@ import { FormSearch } from 'shared/SettingData'; describe("settings/form/SearchForm", () => { describe('render', () => { it('renders SearchForm', () => { - let root = ReactTestRenderer.create(<SearchForm value={FormSearch.fromJSON({ + const root = ReactTestRenderer.create(<SearchForm value={FormSearch.fromJSON({ default: 'google', engines: [['google', 'google.com'], ['yahoo', 'yahoo.com']], })} />).root; - let names = root.findAllByProps({ name: 'name' }); + const names = root.findAllByProps({ name: 'name' }); expect(names).to.have.lengthOf(2); expect(names[0].props.value).to.equal('google'); expect(names[1].props.value).to.equal('yahoo'); - let urls = root.findAllByProps({ name: 'url' }); + const urls = root.findAllByProps({ name: 'url' }); expect(urls).to.have.lengthOf(2); expect(urls[0].props.value).to.equal('google.com'); expect(urls[1].props.value).to.equal('yahoo.com'); @@ -46,7 +46,7 @@ describe("settings/form/SearchForm", () => { engines: [['google', 'google.com'], ['yahoo', 'yahoo.com']] })} onChange={value => { - let json = value.toJSON(); + const json = value.toJSON(); expect(json.default).to.equal('louvre'); expect(json.engines).to.have.lengthOf(2) expect(json.engines).to.have.deep.members( @@ -56,10 +56,10 @@ describe("settings/form/SearchForm", () => { }} />, container); }); - let radio = document.querySelectorAll('input[type=radio]'); + const radio = document.querySelectorAll('input[type=radio]'); radio.checked = true; - let name = document.querySelector('input[name=name]'); + const name = document.querySelector('input[name=name]'); name.value = 'louvre'; ReactTestUtils.Simulate.change(name); @@ -72,7 +72,7 @@ describe("settings/form/SearchForm", () => { engines: [['louvre', 'google.com'], ['yahoo', 'yahoo.com']] })} onChange={value => { - let json = value.toJSON(); + const json = value.toJSON(); expect(json.default).to.equal('yahoo'); expect(json.engines).to.have.lengthOf(1) expect(json.engines).to.have.deep.members( @@ -82,7 +82,7 @@ describe("settings/form/SearchForm", () => { }} />, container); }); - let button = document.querySelector('input[type=button]'); + const button = document.querySelector('input[type=button]'); ReactTestUtils.Simulate.click(button); }); @@ -93,7 +93,7 @@ describe("settings/form/SearchForm", () => { engines: [['google', 'google.com']] })} onChange={value => { - let json = value.toJSON(); + const json = value.toJSON(); expect(json.default).to.equal('yahoo'); expect(json.engines).to.have.lengthOf(2) expect(json.engines).to.have.deep.members( @@ -103,7 +103,7 @@ describe("settings/form/SearchForm", () => { }} />, container); }); - let button = document.querySelector('input[type=button].ui-add-button'); + const button = document.querySelector('input[type=button].ui-add-button'); ReactTestUtils.Simulate.click(button); }); }); diff --git a/test/settings/components/ui/input.test.tsx b/test/settings/components/ui/input.test.tsx index 432efcb..a3e7ff4 100644 --- a/test/settings/components/ui/input.test.tsx +++ b/test/settings/components/ui/input.test.tsx @@ -24,8 +24,8 @@ describe("settings/ui/Input", () => { container); }); - let label = document.querySelector('label'); - let input = document.querySelector('input'); + const label = document.querySelector('label'); + const input = document.querySelector('input'); expect(label.textContent).to.contain('myfield'); expect(input.type).to.contain('text'); expect(input.name).to.contain('myname'); @@ -40,7 +40,7 @@ describe("settings/ui/Input", () => { }}/>, container); }); - let input = document.querySelector('input'); + const input = document.querySelector('input'); input.value = 'newvalue'; ReactTestUtils.Simulate.change(input); }); @@ -54,8 +54,8 @@ describe("settings/ui/Input", () => { container); }); - let label = document.querySelector('label'); - let input = document.querySelector('input'); + const label = document.querySelector('label'); + const input = document.querySelector('input'); expect(label.textContent).to.contain('myfield'); expect(input.type).to.contain('radio'); expect(input.name).to.contain('myname'); @@ -71,7 +71,7 @@ describe("settings/ui/Input", () => { container); }); - let input = document.querySelector('input'); + const input = document.querySelector('input'); input.checked = true; ReactTestUtils.Simulate.change(input); }); @@ -85,9 +85,9 @@ describe("settings/ui/Input", () => { container); }); - let label = document.querySelector('label'); - let textarea = document.querySelector('textarea'); - let error = document.querySelector('.settings-ui-input-error'); + const label = document.querySelector('label'); + const textarea = document.querySelector('textarea'); + const error = document.querySelector('.settings-ui-input-error'); expect(label.textContent).to.contain('myfield'); expect(textarea.nodeName).to.contain('TEXTAREA'); expect(textarea.name).to.contain('myname'); @@ -103,7 +103,7 @@ describe("settings/ui/Input", () => { }}/>, container); }); - let input = document.querySelector('textarea'); + const input = document.querySelector('textarea'); input.value = 'newvalue' ReactTestUtils.Simulate.change(input); }); diff --git a/test/settings/reducers/setting.test.ts b/test/settings/reducers/setting.test.ts index 376d66e..60df061 100644 --- a/test/settings/reducers/setting.test.ts +++ b/test/settings/reducers/setting.test.ts @@ -3,51 +3,51 @@ import settingReducer from 'settings/reducers/setting'; describe("settings setting reducer", () => { it('return the initial state', () => { - let state = settingReducer(undefined, {}); + const state = settingReducer(undefined, {}); expect(state).to.have.deep.property('source', 'json'); expect(state).to.have.deep.property('error', ''); }); it('return next state for SETTING_SET_SETTINGS', () => { - let action = { + const action = { type: actions.SETTING_SET_SETTINGS, source: 'json', json: '{ "key": "value" }', form: {}, }; - let state = settingReducer(undefined, action); + const state = settingReducer(undefined, action); expect(state).to.have.deep.property('source', 'json'); expect(state).to.have.deep.property('json', '{ "key": "value" }'); expect(state).to.have.deep.property('form', {}); }); it('return next state for SETTING_SHOW_ERROR', () => { - let action = { + const action = { type: actions.SETTING_SHOW_ERROR, error: 'bad value', json: '{}', }; - let state = settingReducer(undefined, action); + const state = settingReducer(undefined, action); expect(state).to.have.deep.property('error', 'bad value'); expect(state).to.have.deep.property('json', '{}'); }); it('return next state for SETTING_SWITCH_TO_FORM', () => { - let action = { + const action = { type: actions.SETTING_SWITCH_TO_FORM, form: {}, }; - let state = settingReducer(undefined, action); + const state = settingReducer(undefined, action); expect(state).to.have.deep.property('form', {}); expect(state).to.have.deep.property('source', 'form'); }); it('return next state for SETTING_SWITCH_TO_JSON', () => { - let action = { + const action = { type: actions.SETTING_SWITCH_TO_JSON, json: '{}', }; - let state = settingReducer(undefined, action); + const state = settingReducer(undefined, action); expect(state).to.have.deep.property('json', '{}'); expect(state).to.have.deep.property('source', 'json'); }); |