diff options
Diffstat (limited to 'test')
38 files changed, 279 insertions, 273 deletions
diff --git a/test/background/infrastructures/MemoryStorage.test.ts b/test/background/infrastructures/MemoryStorage.test.ts index 95d3780..ccdf9f0 100644 --- a/test/background/infrastructures/MemoryStorage.test.ts +++ b/test/background/infrastructures/MemoryStorage.test.ts @@ -2,7 +2,7 @@ import MemoryStorage from 'background/infrastructures/MemoryStorage'; describe("background/infrastructures/memory-storage", () => { it('stores values', () => { - let cache = new MemoryStorage(); + const cache = new MemoryStorage(); cache.set('number', 123); expect(cache.get('number')).to.equal(123); @@ -14,7 +14,7 @@ describe("background/infrastructures/memory-storage", () => { }); it('returns undefined if no keys', () => { - let cache = new MemoryStorage(); + const cache = new MemoryStorage(); expect(cache.get('no-keys')).to.be.undefined; }) @@ -23,22 +23,22 @@ describe("background/infrastructures/memory-storage", () => { cache.set('red', 'apple'); cache = new MemoryStorage(); - let got = cache.get('red'); + const got = cache.get('red'); expect(got).to.equal('apple'); }); it('stored cloned objects', () => { - let cache = new MemoryStorage(); - let recipe = { sugar: '300g' }; + const cache = new MemoryStorage(); + const recipe = { sugar: '300g' }; cache.set('recipe', recipe); recipe.salt = '20g' - let got = cache.get('recipe', recipe); + const got = cache.get('recipe', recipe); expect(got).to.deep.equal({ sugar: '300g' }); }); it('throws an error with unserializable objects', () => { - let cache = new MemoryStorage(); + const cache = new MemoryStorage(); expect(() => cache.set('fn', setTimeout)).to.throw(); }) }); diff --git a/test/background/repositories/Mark.test.ts b/test/background/repositories/Mark.test.ts index 167e512..ed1a68e 100644 --- a/test/background/repositories/Mark.test.ts +++ b/test/background/repositories/Mark.test.ts @@ -1,15 +1,14 @@ import MarkRepository from 'background/repositories/MarkRepository'; -import GlobalMark from 'background/domains/GlobalMark'; describe('background/repositories/mark', () => { - let repository; + let repository: MarkRepository; beforeEach(() => { - repository = new MarkRepository; + repository = new MarkRepository(); }); it('get and set', async() => { - let mark = { tabId: 1, url: 'http://example.com', x: 10, y: 30 }; + const mark = { tabId: 1, url: 'http://example.com', x: 10, y: 30 }; repository.setMark('A', mark); diff --git a/test/background/usecases/NavigateUseCase.test.ts b/test/background/usecases/NavigateUseCase.test.ts index ecbf888..48a1c5b 100644 --- a/test/background/usecases/NavigateUseCase.test.ts +++ b/test/background/usecases/NavigateUseCase.test.ts @@ -16,10 +16,10 @@ describe('NavigateUseCase', () => { describe('#openParent()', async () => { it('opens parent directory of file', async() => { - var stub = sinon.stub(tabPresenter, 'getCurrent'); + const stub = sinon.stub(tabPresenter, 'getCurrent'); stub.returns(Promise.resolve({ url: 'https://google.com/fruits/yellow/banana' })) - var mock = sinon.mock(tabPresenter); + const mock = sinon.mock(tabPresenter); mock.expects('open').withArgs('https://google.com/fruits/yellow/'); await sut.openParent(); @@ -28,10 +28,10 @@ describe('NavigateUseCase', () => { }); it('opens parent directory of directory', async() => { - var stub = sinon.stub(tabPresenter, 'getCurrent'); + const stub = sinon.stub(tabPresenter, 'getCurrent'); stub.returns(Promise.resolve({ url: 'https://google.com/fruits/yellow/' })) - var mock = sinon.mock(tabPresenter); + const mock = sinon.mock(tabPresenter); mock.expects('open').withArgs('https://google.com/fruits/'); await sut.openParent(); @@ -40,10 +40,10 @@ describe('NavigateUseCase', () => { }); it('removes hash', async() => { - var stub = sinon.stub(tabPresenter, 'getCurrent'); + const stub = sinon.stub(tabPresenter, 'getCurrent'); stub.returns(Promise.resolve({ url: 'https://google.com/#top' })) - var mock = sinon.mock(tabPresenter); + const mock = sinon.mock(tabPresenter); mock.expects('open').withArgs('https://google.com/'); await sut.openParent(); @@ -52,10 +52,10 @@ describe('NavigateUseCase', () => { }); it('removes search query', async() => { - var stub = sinon.stub(tabPresenter, 'getCurrent'); + const stub = sinon.stub(tabPresenter, 'getCurrent'); stub.returns(Promise.resolve({ url: 'https://google.com/search?q=apple' })) - var mock = sinon.mock(tabPresenter); + const mock = sinon.mock(tabPresenter); mock.expects('open').withArgs('https://google.com/search'); await sut.openParent(); @@ -66,12 +66,12 @@ describe('NavigateUseCase', () => { describe('#openRoot()', () => { it('opens root direectory', async() => { - var stub = sinon.stub(tabPresenter, 'getCurrent'); + const stub = sinon.stub(tabPresenter, 'getCurrent'); stub.returns(Promise.resolve({ url: 'https://google.com/seach?q=apple', })) - var mock = sinon.mock(tabPresenter); + const mock = sinon.mock(tabPresenter); mock.expects('open').withArgs('https://google.com'); await sut.openRoot(); diff --git a/test/background/usecases/filters.test.ts b/test/background/usecases/filters.test.ts index bdfb0be..90541ff 100644 --- a/test/background/usecases/filters.test.ts +++ b/test/background/usecases/filters.test.ts @@ -3,15 +3,15 @@ import * as filters from 'background/usecases/filters'; describe("background/usecases/filters", () => { describe('filterHttp', () => { it('filters http URLs duplicates to https hosts', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/foo' }, { url: 'https://i-beam.org/bar' }, { url: 'http://i-beam.net/hoge' }, { url: 'http://i-beam.net/fuga' }, ]; - let filtered = filters.filterHttp(pages); + const filtered = filters.filterHttp(pages); - let urls = filtered.map(x => x.url); + const urls = filtered.map(x => x.url); expect(urls).to.deep.equal([ 'https://i-beam.org/bar', 'http://i-beam.net/hoge', 'http://i-beam.net/fuga' ]); @@ -20,12 +20,12 @@ describe("background/usecases/filters", () => { describe('filterBlankTitle', () => { it('filters blank titles', () => { - let pages = [ + const pages = [ { title: 'hello' }, { title: '' }, {}, ]; - let filtered = filters.filterBlankTitle(pages); + const filtered = filters.filterBlankTitle(pages); expect(filtered).to.deep.equal([{ title: 'hello' }]); }); @@ -33,15 +33,15 @@ describe("background/usecases/filters", () => { describe('filterByTailingSlash', () => { it('filters duplicated pathname on tailing slash', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/content' }, { url: 'http://i-beam.org/content/' }, { url: 'http://i-beam.org/search' }, { url: 'http://i-beam.org/search?q=apple_banana_cherry' }, ]; - let filtered = filters.filterByTailingSlash(pages); + const filtered = filters.filterByTailingSlash(pages); - let urls = filtered.map(x => x.url); + const urls = filtered.map(x => x.url); expect(urls).to.deep.equal([ 'http://i-beam.org/content', 'http://i-beam.org/search', @@ -52,7 +52,7 @@ describe("background/usecases/filters", () => { describe('filterByPathname', () => { it('remains items less than minimam length', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/search?q=apple' }, { url: 'http://i-beam.org/search?q=apple_banana' }, { url: 'http://i-beam.org/search?q=apple_banana_cherry' }, @@ -60,12 +60,12 @@ describe("background/usecases/filters", () => { { url: 'http://i-beam.org/request?q=apple_banana' }, { url: 'http://i-beam.org/request?q=apple_banana_cherry' }, ]; - let filtered = filters.filterByPathname(pages, 10); + const filtered = filters.filterByPathname(pages, 10); expect(filtered).to.have.lengthOf(6); }); it('filters by length of pathname', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/search?q=apple' }, { url: 'http://i-beam.org/search?q=apple_banana' }, { url: 'http://i-beam.org/search?q=apple_banana_cherry' }, @@ -73,7 +73,7 @@ describe("background/usecases/filters", () => { { url: 'http://i-beam.net/search?q=apple_banana' }, { url: 'http://i-beam.net/search?q=apple_banana_cherry' }, ]; - let filtered = filters.filterByPathname(pages, 0); + const filtered = filters.filterByPathname(pages, 0); expect(filtered).to.deep.equal([ { url: 'http://i-beam.org/search?q=apple' }, { url: 'http://i-beam.net/search?q=apple' }, @@ -83,7 +83,7 @@ describe("background/usecases/filters", () => { describe('filterByOrigin', () => { it('remains items less than minimam length', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/search?q=apple' }, { url: 'http://i-beam.org/search?q=apple_banana' }, { url: 'http://i-beam.org/search?q=apple_banana_cherry' }, @@ -91,12 +91,12 @@ describe("background/usecases/filters", () => { { url: 'http://i-beam.org/request?q=apple_banana' }, { url: 'http://i-beam.org/request?q=apple_banana_cherry' }, ]; - let filtered = filters.filterByOrigin(pages, 10); + const filtered = filters.filterByOrigin(pages, 10); expect(filtered).to.have.lengthOf(6); }); it('filters by length of pathname', () => { - let pages = [ + const pages = [ { url: 'http://i-beam.org/search?q=apple' }, { url: 'http://i-beam.org/search?q=apple_banana' }, { url: 'http://i-beam.org/search?q=apple_banana_cherry' }, @@ -104,7 +104,7 @@ describe("background/usecases/filters", () => { { url: 'http://i-beam.org/request?q=apple_banana' }, { url: 'http://i-beam.org/request?q=apple_banana_cherry' }, ]; - let filtered = filters.filterByOrigin(pages, 0); + const filtered = filters.filterByOrigin(pages, 0); expect(filtered).to.deep.equal([ { url: 'http://i-beam.org/search?q=apple' }, ]); diff --git a/test/background/usecases/parsers.test.ts b/test/background/usecases/parsers.test.ts index f3a64eb..d08de0d 100644 --- a/test/background/usecases/parsers.test.ts +++ b/test/background/usecases/parsers.test.ts @@ -3,13 +3,13 @@ import * as parsers from 'background/usecases/parsers'; describe("shared/commands/parsers", () => { describe("#parsers.parseSetOption", () => { it('parse set string', () => { - let [key, value] = parsers.parseSetOption('hintchars=abcdefgh'); + const [key, value] = parsers.parseSetOption('hintchars=abcdefgh'); expect(key).to.equal('hintchars'); expect(value).to.equal('abcdefgh'); }); it('parse set empty string', () => { - let [key, value] = parsers.parseSetOption('hintchars='); + const [key, value] = parsers.parseSetOption('hintchars='); expect(key).to.equal('hintchars'); expect(value).to.equal(''); }); diff --git a/test/console/actions/console.test.ts b/test/console/actions/console.test.ts index e45d008..583c878 100644 --- a/test/console/actions/console.test.ts +++ b/test/console/actions/console.test.ts @@ -4,13 +4,13 @@ import * as consoleActions from 'console/actions/console'; describe("console actions", () => { describe('hide', () => { it('create CONSOLE_HIDE action', () => { - let action = consoleActions.hide(); + const action = consoleActions.hide(); expect(action.type).to.equal(actions.CONSOLE_HIDE); }); }); describe("showCommand", () => { it('create CONSOLE_SHOW_COMMAND action', () => { - let action = consoleActions.showCommand('hello'); + const action = consoleActions.showCommand('hello'); expect(action.type).to.equal(actions.CONSOLE_SHOW_COMMAND); expect(action.text).to.equal('hello'); }); @@ -18,14 +18,14 @@ describe("console actions", () => { describe("showFind", () => { it('create CONSOLE_SHOW_FIND action', () => { - let action = consoleActions.showFind(); + const action = consoleActions.showFind(); expect(action.type).to.equal(actions.CONSOLE_SHOW_FIND); }); }); describe("showError", () => { it('create CONSOLE_SHOW_ERROR action', () => { - let action = consoleActions.showError('an error'); + const action = consoleActions.showError('an error'); expect(action.type).to.equal(actions.CONSOLE_SHOW_ERROR); expect(action.text).to.equal('an error'); }); @@ -33,7 +33,7 @@ describe("console actions", () => { describe("showInfo", () => { it('create CONSOLE_SHOW_INFO action', () => { - let action = consoleActions.showInfo('an info'); + const action = consoleActions.showInfo('an info'); expect(action.type).to.equal(actions.CONSOLE_SHOW_INFO); expect(action.text).to.equal('an info'); }); @@ -41,14 +41,14 @@ describe("console actions", () => { describe("hideCommand", () => { it('create CONSOLE_HIDE_COMMAND action', () => { - let action = consoleActions.hideCommand(); + const action = consoleActions.hideCommand(); expect(action.type).to.equal(actions.CONSOLE_HIDE_COMMAND); }); }); describe('setConsoleText', () => { it('create CONSOLE_SET_CONSOLE_TEXT action', () => { - let action = consoleActions.setConsoleText('hello world'); + const action = consoleActions.setConsoleText('hello world'); expect(action.type).to.equal(actions.CONSOLE_SET_CONSOLE_TEXT); expect(action.consoleText).to.equal('hello world'); }); @@ -56,14 +56,14 @@ describe("console actions", () => { describe("completionPrev", () => { it('create CONSOLE_COMPLETION_PREV action', () => { - let action = consoleActions.completionPrev(); + const action = consoleActions.completionPrev(); expect(action.type).to.equal(actions.CONSOLE_COMPLETION_PREV); }); }); describe("completionNext", () => { it('create CONSOLE_COMPLETION_NEXT action', () => { - let action = consoleActions.completionNext(); + const action = consoleActions.completionNext(); expect(action.type).to.equal(actions.CONSOLE_COMPLETION_NEXT); }); }); diff --git a/test/console/components/console/Completion.test.tsx b/test/console/components/console/Completion.test.tsx index 16bf11a..e411c4a 100644 --- a/test/console/components/console/Completion.test.tsx +++ b/test/console/components/console/Completion.test.tsx @@ -3,7 +3,7 @@ import Completion from 'console/components/console/Completion' import ReactTestRenderer from 'react-test-renderer'; describe("console/components/console/completion", () => { - let completions = [{ + const completions = [{ name: "Fruit", items: [{ caption: "apple" }, { caption: "banana" }, { caption: "cherry" }], }, { @@ -12,14 +12,14 @@ describe("console/components/console/completion", () => { }]; it('renders Completion component', () => { - let root = ReactTestRenderer.create(<Completion + const root = ReactTestRenderer.create(<Completion completions={completions} size={30} />).root; expect(root.children).to.have.lengthOf(1); - let children = root.children[0].children; + const children = root.children[0].children; expect(children).to.have.lengthOf(8); expect(children[0].props.title).to.equal('Fruit'); expect(children[1].props.caption).to.equal('apple'); @@ -32,25 +32,25 @@ describe("console/components/console/completion", () => { }); it('highlight current item', () => { - let root = ReactTestRenderer.create(<Completion + const root = ReactTestRenderer.create(<Completion completions={completions} size={30} select={3} />).root; - let children = root.children[0].children; + const children = root.children[0].children; expect(children[5].props.highlight).to.be.true; }); it('does not highlight any items', () => { - let root = ReactTestRenderer.create(<Completion + const root = ReactTestRenderer.create(<Completion completions={completions} size={30} select={-1} />).root; - let children = root.children[0].children; - for (let li of children[0].children) { + const children = root.children[0].children; + for (const li of children[0].children) { expect(li.props.highlight).not.to.be.ok; } }); @@ -79,13 +79,12 @@ describe("console/components/console/completion", () => { }) it('scrolls up to down with select', () => { - let component = ReactTestRenderer.create(<Completion + const component = ReactTestRenderer.create(<Completion completions={completions} size={3} select={1} />); - let instance = component.getInstance(); - let root = component.root; + const root = component.root; let children = root.children[0].children; expect(children).to.have.lengthOf(3); @@ -121,13 +120,12 @@ describe("console/components/console/completion", () => { }); it('scrolls down to up with select', () => { - let component = ReactTestRenderer.create(<Completion + const component = ReactTestRenderer.create(<Completion completions={completions} size={3} select={5} />); - let root = component.root; - let instance = component.getInstance(); + const root = component.root; let children = root.children[0].children; expect(children).to.have.lengthOf(3); diff --git a/test/console/reducers/console.test.ts b/test/console/reducers/console.test.ts index 47e7daf..038e712 100644 --- a/test/console/reducers/console.test.ts +++ b/test/console/reducers/console.test.ts @@ -3,7 +3,7 @@ import reducer from 'console/reducers'; describe("console reducer", () => { it('return the initial state', () => { - let state = reducer(undefined, {}); + const state = reducer(undefined, {}); expect(state).to.have.property('mode', ''); expect(state).to.have.property('messageText', ''); expect(state).to.have.property('consoleText', ''); @@ -12,34 +12,34 @@ describe("console reducer", () => { }); it('return next state for CONSOLE_HIDE', () => { - let action = { type: actions.CONSOLE_HIDE }; - let state = reducer({ mode: 'error' }, action); + const action = { type: actions.CONSOLE_HIDE }; + const state = reducer({ mode: 'error' }, action); expect(state).to.have.property('mode', ''); }) it('return next state for CONSOLE_SHOW_COMMAND', () => { - let action = { type: actions.CONSOLE_SHOW_COMMAND, text: 'open ' }; - let state = reducer({}, action); + const action = { type: actions.CONSOLE_SHOW_COMMAND, text: 'open ' }; + const state = reducer({}, action); expect(state).to.have.property('mode', 'command'); expect(state).to.have.property('consoleText', 'open '); }); it('return next state for CONSOLE_SHOW_INFO', () => { - let action = { type: actions.CONSOLE_SHOW_INFO, text: 'an info' }; - let state = reducer({}, action); + const action = { type: actions.CONSOLE_SHOW_INFO, text: 'an info' }; + const state = reducer({}, action); expect(state).to.have.property('mode', 'info'); expect(state).to.have.property('messageText', 'an info'); }); it('return next state for CONSOLE_SHOW_ERROR', () => { - let action = { type: actions.CONSOLE_SHOW_ERROR, text: 'an error' }; - let state = reducer({}, action); + const action = { type: actions.CONSOLE_SHOW_ERROR, text: 'an error' }; + const state = reducer({}, action); expect(state).to.have.property('mode', 'error'); expect(state).to.have.property('messageText', 'an error'); }); it('return next state for CONSOLE_HIDE_COMMAND', () => { - let action = { type: actions.CONSOLE_HIDE_COMMAND }; + const action = { type: actions.CONSOLE_HIDE_COMMAND }; let state = reducer({ mode: 'command' }, action); expect(state).to.have.property('mode', ''); @@ -48,11 +48,11 @@ describe("console reducer", () => { }); it('return next state for CONSOLE_SET_CONSOLE_TEXT', () => { - let action = { + const action = { type: actions.CONSOLE_SET_CONSOLE_TEXT, consoleText: 'hello world' } - let state = reducer({}, action) + const state = reducer({}, action) expect(state).to.have.property('consoleText', 'hello world'); }); @@ -62,7 +62,7 @@ describe("console reducer", () => { select: 0, completions: [], } - let action = { + const action = { type: actions.CONSOLE_SET_COMPLETIONS, completions: [{ name: 'Apple', @@ -78,7 +78,7 @@ describe("console reducer", () => { }); it ('return next state for CONSOLE_COMPLETION_NEXT', () => { - let action = { type: actions.CONSOLE_COMPLETION_NEXT }; + const action = { type: actions.CONSOLE_COMPLETION_NEXT }; let state = { select: -1, completions: [{ @@ -104,7 +104,7 @@ describe("console reducer", () => { }); it ('return next state for CONSOLE_COMPLETION_PREV', () => { - let action = { type: actions.CONSOLE_COMPLETION_PREV }; + const action = { type: actions.CONSOLE_COMPLETION_PREV }; let state = { select: -1, completions: [{ diff --git a/test/content/InputDriver.test.ts b/test/content/InputDriver.test.ts index 441d107..d3a55dd 100644 --- a/test/content/InputDriver.test.ts +++ b/test/content/InputDriver.test.ts @@ -50,7 +50,7 @@ describe('InputDriver', () => { return true; }); - let events = [ + const events = [ new KeyboardEvent('keydown', { key: 'a' }), new KeyboardEvent('keydown', { key: 'b' }), new KeyboardEvent('keypress', { key: 'a' }), @@ -58,7 +58,7 @@ describe('InputDriver', () => { new KeyboardEvent('keypress', { key: 'b' }), new KeyboardEvent('keyup', { key: 'b' }), ]; - for (let e of events) { + for (const e of events) { target.dispatchEvent(e); } @@ -102,9 +102,9 @@ describe('InputDriver', () => { it('ignores events from input elements', () => { ['input', 'textarea', 'select'].forEach((name) => { - let input = window.document.createElement(name); - let driver = new InputDriver(input); - driver.onKey((key: Key): boolean => { + const input = window.document.createElement(name); + const driver = new InputDriver(input); + driver.onKey((_key: Key): boolean => { expect.fail(); return false; }); @@ -113,8 +113,8 @@ describe('InputDriver', () => { }); it('ignores events from contenteditable elements', () => { - let div = window.document.createElement('div'); - let driver = new InputDriver(div); + const div = window.document.createElement('div'); + const driver = new InputDriver(div); driver.onKey((_key: Key): boolean => { expect.fail(); return false; @@ -130,7 +130,7 @@ describe('InputDriver', () => { describe("#keyFromKeyboardEvent", () => { it('returns from keyboard input Ctrl+X', () => { - let k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { + const k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { key: 'x', shiftKey: false, ctrlKey: true, altKey: false, metaKey: true, })); expect(k.key).to.equal('x'); @@ -141,7 +141,7 @@ describe("#keyFromKeyboardEvent", () => { }); it('returns from keyboard input Shift+Esc', () => { - let k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { + const k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { key: 'Escape', shiftKey: true, ctrlKey: false, altKey: false, metaKey: true })); expect(k.key).to.equal('Esc'); @@ -153,7 +153,7 @@ describe("#keyFromKeyboardEvent", () => { it('returns from keyboard input Ctrl+$', () => { // $ required shift pressing on most keyboards - let k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { + const k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { key: '$', shiftKey: true, ctrlKey: true, altKey: false, metaKey: false })); expect(k.key).to.equal('$'); @@ -164,7 +164,7 @@ describe("#keyFromKeyboardEvent", () => { }); it('returns from keyboard input Crtl+Space', () => { - let k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { + const k = keyFromKeyboardEvent(new KeyboardEvent('keydown', { key: ' ', shiftKey: false, ctrlKey: true, altKey: false, metaKey: false })); expect(k.key).to.equal('Space'); diff --git a/test/content/domains/KeySequence.test.ts b/test/content/domains/KeySequence.test.ts index bc16189..5df5217 100644 --- a/test/content/domains/KeySequence.test.ts +++ b/test/content/domains/KeySequence.test.ts @@ -5,7 +5,7 @@ import Key from "../../../src/shared/settings/Key"; describe("KeySequence", () => { describe('#push', () => { it('append a key to the sequence', () => { - let seq = new KeySequence([]); + const seq = new KeySequence([]); seq.push(Key.fromMapKey('g')); seq.push(Key.fromMapKey('<S-U>')); @@ -17,7 +17,7 @@ describe("KeySequence", () => { describe('#startsWith', () => { it('returns true if the key sequence starts with param', () => { - let seq = new KeySequence([ + const seq = new KeySequence([ Key.fromMapKey('g'), Key.fromMapKey('<S-U>'), ]); @@ -39,7 +39,7 @@ describe("KeySequence", () => { }); it('returns true if the empty sequence starts with an empty sequence', () => { - let seq = new KeySequence([]); + const seq = new KeySequence([]); expect(seq.startsWith(new KeySequence([]))).to.be.true; expect(seq.startsWith(new KeySequence([ @@ -102,7 +102,7 @@ describe("KeySequence", () => { describe('#trimNumericPrefix', () => { it('removes numeric prefix', () => { - let seq = new KeySequence([ + const seq = new KeySequence([ new Key({ key: '1' }), new Key({ key: '0' }) , new Key({ key: 'g' }), new Key({ key: 'g' }) , new Key({ key: '3' }) , ]).trimNumericPrefix(); @@ -110,14 +110,14 @@ describe("KeySequence", () => { }); it('returns empty if keys contains only digis', () => { - let seq = new KeySequence([ + const seq = new KeySequence([ new Key({ key: '1' }), new Key({ key: '0' }) , ]).trimNumericPrefix(); expect(seq.trimNumericPrefix().keys).to.be.empty; }); it('returns itself if no numeric prefix', () => { - let seq = new KeySequence([ + const seq = new KeySequence([ new Key({ key: 'g' }), new Key({ key: 'g' }) , new Key({ key: '3' }) , ]).trimNumericPrefix(); @@ -144,14 +144,14 @@ describe("KeySequence", () => { describe('#fromMapKeys', () => { it('returns mapped keys for Shift+Esc', () => { - let keys = KeySequence.fromMapKeys('<S-Esc>').keys; + const keys = KeySequence.fromMapKeys('<S-Esc>').keys; expect(keys).to.have.lengthOf(1); expect(keys[0].key).to.equal('Esc'); expect(keys[0].shift).to.be.true; }); it('returns mapped keys for a<C-B><A-C>d<M-e>', () => { - let keys = KeySequence.fromMapKeys('a<C-B><A-C>d<M-e>').keys; + const keys = KeySequence.fromMapKeys('a<C-B><A-C>d<M-e>').keys; expect(keys).to.have.lengthOf(5); expect(keys[0].key).to.equal('a'); expect(keys[1].ctrl).to.be.true; diff --git a/test/content/presenters/Hint.test.ts b/test/content/presenters/Hint.test.ts index 7994788..7daa63d 100644 --- a/test/content/presenters/Hint.test.ts +++ b/test/content/presenters/Hint.test.ts @@ -11,43 +11,43 @@ describe('Hint', () => { describe('#constructor', () => { it('creates a hint element with tag name', () => { - let link = document.getElementById('test-link'); - let hint = new Hint(link, 'abc'); + const link = document.getElementById('test-link'); + new Hint(link, 'abc'); - let elem = document.querySelector('.vimvixen-hint'); + const elem = document.querySelector('.vimvixen-hint'); expect(elem.textContent.trim()).to.be.equal('abc'); }); }); describe('#show', () => { it('shows an element', () => { - let link = document.getElementById('test-link'); - let hint = new Hint(link, 'abc'); + const link = document.getElementById('test-link'); + const hint = new Hint(link, 'abc'); hint.hide(); hint.show(); - let elem = document.querySelector('.vimvixen-hint') as HTMLElement; + const elem = document.querySelector('.vimvixen-hint') as HTMLElement; expect(elem.style.display).to.not.equal('none'); }); }); describe('#hide', () => { it('hides an element', () => { - let link = document.getElementById('test-link') as HTMLElement; - let hint = new Hint(link, 'abc'); + const link = document.getElementById('test-link') as HTMLElement; + const hint = new Hint(link, 'abc'); hint.hide(); - let elem = document.querySelector('.vimvixen-hint') as HTMLElement; + const elem = document.querySelector('.vimvixen-hint') as HTMLElement; expect(elem.style.display).to.equal('none'); }); }); describe('#remove', () => { it('removes an element', () => { - let link = document.getElementById('test-link'); - let hint = new Hint(link, 'abc'); + const link = document.getElementById('test-link'); + const hint = new Hint(link, 'abc'); - let elem = document.querySelector('.vimvixen-hint'); + const elem = document.querySelector('.vimvixen-hint'); expect(elem.parentElement).to.not.be.null; hint.remove(); expect(elem.parentElement).to.be.null; @@ -66,8 +66,8 @@ describe('LinkHint', () => { describe('#getLink()', () => { it('returns value of "href" attribute', () => { - let link = document.getElementById('test-link1') as HTMLAnchorElement; - let hint = new LinkHint(link, 'abc'); + const link = document.getElementById('test-link1') as HTMLAnchorElement; + const hint = new LinkHint(link, 'abc'); expect(hint.getLink()).to.equal('https://google.com/'); }); @@ -89,8 +89,8 @@ describe('LinkHint', () => { describe('#click()', () => { it('clicks a element', (done) => { - let link = document.getElementById('test-link3') as HTMLAnchorElement; - let hint = new LinkHint(link, 'abc'); + const link = document.getElementById('test-link3') as HTMLAnchorElement; + const hint = new LinkHint(link, 'abc'); link.onclick = () => { done() }; hint.click(); @@ -106,8 +106,8 @@ describe('InputHint', () => { }); it('focuses to the input', () => { - let input = document.getElementById('test-input') as HTMLInputElement; - let hint = new InputHint(input, 'abc'); + const input = document.getElementById('test-input') as HTMLInputElement; + const hint = new InputHint(input, 'abc'); hint.activate(); expect(document.activeElement).to.equal(input); @@ -120,8 +120,8 @@ describe('InputHint', () => { }); it('checks and focuses to the input', () => { - let input = document.getElementById('test-input') as HTMLInputElement; - let hint = new InputHint(input, 'abc'); + const input = document.getElementById('test-input') as HTMLInputElement; + const hint = new InputHint(input, 'abc'); hint.activate(); expect(input.checked).to.be.true; @@ -133,8 +133,8 @@ describe('InputHint', () => { }); it('focuses to the textarea', () => { - let textarea = document.getElementById('test-textarea') as HTMLTextAreaElement; - let hint = new InputHint(textarea, 'abc'); + const textarea = document.getElementById('test-textarea') as HTMLTextAreaElement; + const hint = new InputHint(textarea, 'abc'); hint.activate(); expect(document.activeElement).to.equal(textarea); @@ -147,10 +147,10 @@ describe('InputHint', () => { }); it('clicks the button', (done) => { - let button = document.getElementById('test-button') as HTMLButtonElement; + const button = document.getElementById('test-button') as HTMLButtonElement; button.onclick = () => { done() }; - let hint = new InputHint(button, 'abc'); + const hint = new InputHint(button, 'abc'); hint.activate(); }); }); diff --git a/test/content/presenters/NavigationPresenter.test.ts b/test/content/presenters/NavigationPresenter.test.ts index 5b6a8ca..6aa057b 100644 --- a/test/content/presenters/NavigationPresenter.test.ts +++ b/test/content/presenters/NavigationPresenter.test.ts @@ -1,9 +1,8 @@ -import NavigationPresenter, { NavigationPresenterImpl } - from '../../../src/content/presenters/NavigationPresenter'; +import { NavigationPresenterImpl } from '../../../src/content/presenters/NavigationPresenter'; import { expect } from 'chai'; -describe('NavigationPresenter', () => { - let sut; +describe('NavigationPresenterImpl', () => { + let sut: NavigationPresenterImpl; const testRel = (done, rel, html) => { const method = rel === 'prev' ? sut.openLinkPrev.bind(sut) : sut.openLinkNext.bind(sut); diff --git a/test/content/repositories/AddonEnabledRepository.test.ts b/test/content/repositories/AddonEnabledRepository.test.ts index 3cea897..7edd50e 100644 --- a/test/content/repositories/AddonEnabledRepository.test.ts +++ b/test/content/repositories/AddonEnabledRepository.test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; describe('AddonEnabledRepositoryImpl', () => { it('updates and gets current value', () => { - let sut = new AddonEnabledRepositoryImpl(); + const sut = new AddonEnabledRepositoryImpl(); sut.set(true); expect(sut.get()).to.be.true; diff --git a/test/content/repositories/FindRepository.test.ts b/test/content/repositories/FindRepository.test.ts index dcb2dff..0e50b0a 100644 --- a/test/content/repositories/FindRepository.test.ts +++ b/test/content/repositories/FindRepository.test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; describe('FindRepositoryImpl', () => { it('updates and gets last keyword', () => { - let sut = new FindRepositoryImpl(); + const sut = new FindRepositoryImpl(); expect(sut.getLastKeyword()).to.be.null; diff --git a/test/content/repositories/FollowMasterRepository.test.ts b/test/content/repositories/FollowMasterRepository.test.ts index 8c3f34e..3eb172f 100644 --- a/test/content/repositories/FollowMasterRepository.test.ts +++ b/test/content/repositories/FollowMasterRepository.test.ts @@ -25,7 +25,7 @@ describe('FollowMasterRepositoryImpl', () => { describe('#getTagsByPrefix', () => { it('gets tags matched by prefix', () => { - for (let tag of ['a', 'aa', 'ab', 'b', 'ba', 'bb']) { + for (const tag of ['a', 'aa', 'ab', 'b', 'ba', 'bb']) { sut.addTag(tag); } expect(sut.getTagsByPrefix('a')).to.deep.equal(['a', 'aa', 'ab']); diff --git a/test/content/repositories/KeymapRepository.test.ts b/test/content/repositories/KeymapRepository.test.ts index df013df..68f515c 100644 --- a/test/content/repositories/KeymapRepository.test.ts +++ b/test/content/repositories/KeymapRepository.test.ts @@ -12,11 +12,11 @@ describe('KeymapRepositoryImpl', () => { describe('#enqueueKey()', () => { it('enqueues keys', () => { - sut.enqueueKey(Key.fromMapKey('a'); - sut.enqueueKey(Key.fromMapKey('b'); - let sequence = sut.enqueueKey(Key.fromMapKey('c')); + sut.enqueueKey(Key.fromMapKey('a')); + sut.enqueueKey(Key.fromMapKey('b')); + const sequence = sut.enqueueKey(Key.fromMapKey('c')); - let keys = sequence.keys; + const keys = sequence.keys; expect(keys[0].equals(Key.fromMapKey('a'))).to.be.true; expect(keys[1].equals(Key.fromMapKey('b'))).to.be.true; expect(keys[2].equals(Key.fromMapKey('c'))).to.be.true; @@ -30,7 +30,7 @@ describe('KeymapRepositoryImpl', () => { sut.enqueueKey(Key.fromMapKey('c')); sut.clear(); - let sequence = sut.enqueueKey(Key.fromMapKey('a')); + const sequence = sut.enqueueKey(Key.fromMapKey('a')); expect(sequence.length()).to.equal(1); }); }); diff --git a/test/content/repositories/MarkRepository.test.ts b/test/content/repositories/MarkRepository.test.ts index 7fced5f..6ddd38d 100644 --- a/test/content/repositories/MarkRepository.test.ts +++ b/test/content/repositories/MarkRepository.test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; describe('MarkRepositoryImpl', () => { it('save and load marks', () => { - let sut = new MarkRepositoryImpl(); + const sut = new MarkRepositoryImpl(); sut.set('a', { x: 10, y: 20 }); expect(sut.get('a')).to.deep.equal({ x: 10, y: 20 }); diff --git a/test/content/repositories/SettingRepository.test.ts b/test/content/repositories/SettingRepository.test.ts index db4c528..e45d7c4 100644 --- a/test/content/repositories/SettingRepository.test.ts +++ b/test/content/repositories/SettingRepository.test.ts @@ -4,9 +4,9 @@ import Settings from '../../../src/shared/settings/Settings'; describe('SettingRepositoryImpl', () => { it('updates and gets current value', () => { - let sut = new SettingRepositoryImpl(); + const sut = new SettingRepositoryImpl(); - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: {}, search:{ default: 'google', @@ -24,7 +24,7 @@ describe('SettingRepositoryImpl', () => { sut.set(settings); - let actual = sut.get(); + const actual = sut.get(); expect(actual.properties.hintchars).to.equal('abcd1234'); }); }); diff --git a/test/content/usecases/ClipboardUseCase.test.ts b/test/content/usecases/ClipboardUseCase.test.ts index a863651..3cc82fe 100644 --- a/test/content/usecases/ClipboardUseCase.test.ts +++ b/test/content/usecases/ClipboardUseCase.test.ts @@ -6,19 +6,31 @@ import ConsoleClient from '../../../src/content/client/ConsoleClient'; import * as sinon from 'sinon'; import { expect } from 'chai'; +import {Operation} from "../../../src/shared/operations"; describe('ClipboardUseCase', () => { let clipboardRepository: ClipboardRepository; + let operationClient: OperationClient; + let consoleClient: ConsoleClient; + let sut: ClipboardUseCase; beforeEach(() => { - var modal = <ConsoleClient>{}; + clipboardRepository = new class implements ClipboardRepository { + read(): string { return ""; } + write(_text: string) {} + }; + operationClient = new class implements OperationClient { + execBackgroundOp(_repeat: number, _op: Operation): Promise<void> { return Promise.resolve() } + internalOpenUrl(_url: string, _newTab?: boolean, _background?: boolean): Promise<void> { return Promise.resolve() } + }; + consoleClient = new class implements ConsoleClient { + error(_text: string): Promise<void> { return Promise.resolve() } + info(_text: string): Promise<void> { return Promise.resolve() } + }; - clipboardRepository = <ClipboardRepository>{ read() {}, write(_) {} }; - operationClient = <OperationClient>{ internalOpenUrl(_) {} }; - consoleClient = <ConsoleClient>{ info(_) {}}; sut = new ClipboardUseCase( clipboardRepository, new SettingRepositoryImpl(), @@ -29,13 +41,13 @@ describe('ClipboardUseCase', () => { describe('#yankCurrentURL', () => { it('yanks current url', async () => { - let href = window.location.href; - var mockRepository = sinon.mock(clipboardRepository); + const href = window.location.href; + const mockRepository = sinon.mock(clipboardRepository); mockRepository.expects('write').withArgs(href); - var mockConsoleClient = sinon.mock(consoleClient); + const mockConsoleClient = sinon.mock(consoleClient); mockConsoleClient.expects('info').withArgs('Yanked ' + href); - let yanked = await sut.yankCurrentURL(); + const yanked = await sut.yankCurrentURL(); expect(yanked).to.equal(href); mockRepository.verify(); @@ -45,9 +57,9 @@ describe('ClipboardUseCase', () => { describe('#openOrSearch', () => { it('opens url from the clipboard', async () => { - let url = 'https://github.com/ueokande/vim-vixen' + const url = 'https://github.com/ueokande/vim-vixen' sinon.stub(clipboardRepository, 'read').returns(url); - let mockOperationClient = sinon.mock(operationClient); + const mockOperationClient = sinon.mock(operationClient); mockOperationClient.expects('internalOpenUrl').withArgs(url, true); await sut.openOrSearch(true); @@ -56,9 +68,9 @@ describe('ClipboardUseCase', () => { }); it('opens search results from the clipboard', async () => { - let url = 'https://google.com/search?q=banana'; + const url = 'https://google.com/search?q=banana'; sinon.stub(clipboardRepository, 'read').returns('banana'); - let mockOperationClient = sinon.mock(operationClient); + const mockOperationClient = sinon.mock(operationClient); mockOperationClient.expects('internalOpenUrl').withArgs(url, true); await sut.openOrSearch(true); diff --git a/test/content/usecases/FindUseCase.test.ts b/test/content/usecases/FindUseCase.test.ts index ddd4cd4..3978dbc 100644 --- a/test/content/usecases/FindUseCase.test.ts +++ b/test/content/usecases/FindUseCase.test.ts @@ -32,7 +32,7 @@ class MockFindPresenter implements FindPresenter { } find(keyword: string, _backward: boolean): boolean { - let found = this.document.includes(keyword); + const found = this.document.includes(keyword); this.highlighted = found; return found; } diff --git a/test/content/usecases/HintKeyProducer.test.ts b/test/content/usecases/HintKeyProducer.test.ts index feafffb..5841ae9 100644 --- a/test/content/usecases/HintKeyProducer.test.ts +++ b/test/content/usecases/HintKeyProducer.test.ts @@ -10,13 +10,13 @@ describe('HintKeyProducer class', () => { describe('#produce', () => { it('produce incremented keys', () => { - let charset = 'abc'; - let sequences = [ + const charset = 'abc'; + const sequences = [ 'a', 'b', 'c', 'aa', 'ab', 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc', 'aaa', 'aab', 'aac', 'aba'] - let producer = new HintKeyProducer(charset); + const producer = new HintKeyProducer(charset); for (let i = 0; i < sequences.length; ++i) { expect(producer.produce()).to.equal(sequences[i]); } diff --git a/test/content/usecases/KeymapUseCase.test.ts b/test/content/usecases/KeymapUseCase.test.ts index 598d5a3..032d4fc 100644 --- a/test/content/usecases/KeymapUseCase.test.ts +++ b/test/content/usecases/KeymapUseCase.test.ts @@ -52,7 +52,7 @@ class MockAddressRepository implements AddressRepository { describe('KeymapUseCase', () => { context('with no-digis keymaps', () => { - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: { k: {type: 'scroll.vertically', count: -1}, j: {type: 'scroll.vertically', count: 1}, @@ -88,7 +88,7 @@ describe('KeymapUseCase', () => { }); context('when keymaps containing numeric mappings', () => { - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: { 20: {type: "scroll.top"}, g5: {type: 'scroll.bottom'}, @@ -132,7 +132,7 @@ describe('KeymapUseCase', () => { }); context('when the keys are mismatched with the operations', () => { - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: { gg: {type: "scroll.top"}, G: {type: "scroll.bottom"}, @@ -170,7 +170,7 @@ describe('KeymapUseCase', () => { }); context('when the site matches to the blacklist', () => { - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: { k: {type: 'scroll.vertically', count: -1}, a: {type: 'addon.enable'}, @@ -197,7 +197,7 @@ describe('KeymapUseCase', () => { }); context('when the site matches to the partial blacklist', () => { - let settings = Settings.fromJSON({ + const settings = Settings.fromJSON({ keymaps: { k: {type: 'scroll.vertically', count: -1}, j: {type: 'scroll.vertically', count: 1}, diff --git a/test/content/usecases/SettingUseCaase.test.ts b/test/content/usecases/SettingUseCaase.test.ts index 136c5af..cf14e6e 100644 --- a/test/content/usecases/SettingUseCaase.test.ts +++ b/test/content/usecases/SettingUseCaase.test.ts @@ -38,7 +38,7 @@ describe('AddonEnabledUseCase', () => { let sut: SettingUseCase; beforeEach(() => { - let testSettings = { + const testSettings = { keymaps: {}, search: { default: 'google', @@ -61,10 +61,10 @@ describe('AddonEnabledUseCase', () => { describe('#reload', () => { it('loads settings and store to repository', async() => { - let settings = await sut.reload(); + const settings = await sut.reload(); expect(settings.properties.hintchars).to.equal('abcd1234'); - let saved = repository.get(); + const saved = repository.get(); expect(saved.properties.hintchars).to.equal('abcd1234'); }); }); diff --git a/test/main.ts b/test/main.ts index 433b531..c985546 100644 --- a/test/main.ts +++ b/test/main.ts @@ -1,8 +1,6 @@ import 'reflect-metadata'; import { expect } from 'chai'; - -const browserFake = require('webextensions-api-fake'); -const browser = browserFake(); +import browserFake from 'webextensions-api-fake'; global.expect = expect; -global.browser = browser; +global.browser = browserFake(); 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'); }); diff --git a/test/shared/SettingData.test.ts b/test/shared/SettingData.test.ts index 5de7770..0632176 100644 --- a/test/shared/SettingData.test.ts +++ b/test/shared/SettingData.test.ts @@ -9,12 +9,12 @@ describe('shared/SettingData', () => { describe('FormKeymaps', () => { describe('#valueOF to #toKeymaps', () => { it('parses form keymaps and convert to operations', () => { - let data = { + const data = { 'scroll.vertically?{"count":1}': 'j', 'scroll.home': '0', }; - let keymaps = FormKeymaps.fromJSON(data).toKeymaps().toJSON(); + const keymaps = FormKeymaps.fromJSON(data).toKeymaps().toJSON(); expect(keymaps).to.deep.equal({ 'j': { type: 'scroll.vertically', count: 1 }, '0': { type: 'scroll.home' }, @@ -24,12 +24,12 @@ describe('shared/SettingData', () => { describe('#fromKeymaps to #toJSON', () => { it('create from a Keymaps and create a JSON object', () => { - let keymaps: Keymaps = Keymaps.fromJSON({ + const keymaps: Keymaps = Keymaps.fromJSON({ 'j': { type: 'scroll.vertically', count: 1 }, '0': { type: 'scroll.home' }, }); - let form = FormKeymaps.fromKeymaps(keymaps).toJSON(); + const form = FormKeymaps.fromKeymaps(keymaps).toJSON(); expect(form).to.deep.equal({ 'scroll.vertically?{"count":1}': 'j', 'scroll.home': '0', @@ -41,7 +41,7 @@ describe('shared/SettingData', () => { describe('JSONSettings', () => { describe('#valueOf to #toSettings', () => { it('parse object and create a Settings', () => { - let o = `{ + const o = `{ "keymaps": {}, "search": { "default": "google", @@ -57,14 +57,14 @@ describe('shared/SettingData', () => { "blacklist": [] }`; - let settings = JSONTextSettings.fromText(o).toSettings(); + const settings = JSONTextSettings.fromText(o).toSettings(); expect(settings.toJSON()).to.deep.equal(JSON.parse(o)); }); }); describe('#fromSettings to #toJSON', () => { it('create from a Settings and create a JSON string', () => { - let o = Settings.fromJSON({ + const o = Settings.fromJSON({ keymaps: {}, search: { default: "google", @@ -80,7 +80,7 @@ describe('shared/SettingData', () => { blacklist: [], }); - let json = JSONTextSettings.fromSettings(o).toJSONText(); + const json = JSONTextSettings.fromSettings(o).toJSONText(); expect(JSON.parse(json)).to.deep.equal(o.toJSON()); }); }); @@ -89,7 +89,7 @@ describe('shared/SettingData', () => { describe('FormSettings', () => { describe('#valueOf to #toSettings', () => { it('parse object and create a Settings', () => { - let data = { + const data = { keymaps: { 'scroll.vertically?{"count":1}': 'j', 'scroll.home': '0', @@ -108,7 +108,7 @@ describe('shared/SettingData', () => { blacklist: [] }; - let settings = FormSettings.fromJSON(data).toSettings(); + const settings = FormSettings.fromJSON(data).toSettings(); expect(settings.toJSON()).to.deep.equal({ keymaps: { 'j': { type: 'scroll.vertically', count: 1 }, @@ -132,7 +132,7 @@ describe('shared/SettingData', () => { describe('#fromSettings to #toJSON', () => { it('create from a Settings and create a JSON string', () => { - let data: Settings = Settings.fromJSON({ + const data: Settings = Settings.fromJSON({ keymaps: { 'j': { type: 'scroll.vertically', count: 1 }, '0': { type: 'scroll.home' }, @@ -151,7 +151,7 @@ describe('shared/SettingData', () => { blacklist: [], }); - let json = FormSettings.fromSettings(data).toJSON(); + const json = FormSettings.fromSettings(data).toJSON(); expect(json).to.deep.equal({ keymaps: { 'scroll.vertically?{"count":1}': 'j', @@ -177,7 +177,7 @@ describe('shared/SettingData', () => { describe('SettingData', () => { describe('#valueOf to #toJSON', () => { it('parse object from json source', () => { - let data = { + const data = { source: 'json', json: `{ "keymaps": {}, @@ -196,13 +196,13 @@ describe('shared/SettingData', () => { }`, }; - let j = SettingData.fromJSON(data).toJSON(); + const j = SettingData.fromJSON(data).toJSON(); expect(j.source).to.equal('json'); expect(j.json).to.be.a('string'); }); it('parse object from form source', () => { - let data = { + const data = { source: 'form', form: { keymaps: {}, @@ -221,7 +221,7 @@ describe('shared/SettingData', () => { }, }; - let j = SettingData.fromJSON(data).toJSON(); + const j = SettingData.fromJSON(data).toJSON(); expect(j.source).to.equal('form'); expect(j.form).to.deep.equal({ keymaps: {}, @@ -243,7 +243,7 @@ describe('shared/SettingData', () => { describe('#toSettings', () => { it('parse object from json source', () => { - let data = { + const data = { source: 'json', json: `{ "keymaps": {}, @@ -262,12 +262,12 @@ describe('shared/SettingData', () => { }`, }; - let settings = SettingData.fromJSON(data).toSettings(); + const settings = SettingData.fromJSON(data).toSettings(); expect(settings.search.defaultEngine).to.equal('google'); }); it('parse object from form source', () => { - let data = { + const data = { source: 'form', form: { keymaps: {}, @@ -286,7 +286,7 @@ describe('shared/SettingData', () => { }, }; - let settings = SettingData.fromJSON(data).toSettings(); + const settings = SettingData.fromJSON(data).toSettings(); expect(settings.search.defaultEngine).to.equal('yahoo'); }); }); diff --git a/test/shared/operations.test.ts b/test/shared/operations.test.ts index 42a3eed..fbb6193 100644 --- a/test/shared/operations.test.ts +++ b/test/shared/operations.test.ts @@ -3,7 +3,7 @@ import * as operations from 'shared/operations'; describe('operations', () => { describe('#valueOf', () => { it('returns an Operation', () => { - let op: operations.Operation = operations.valueOf({ + const op: operations.Operation = operations.valueOf({ type: operations.SCROLL_VERTICALLY, count: 10, }); @@ -18,7 +18,7 @@ describe('operations', () => { }); it('fills default valus of optional parameter', () => { - let op: operations.Operation = operations.valueOf({ + const op: operations.Operation = operations.valueOf({ type: operations.COMMAND_SHOW_OPEN, }); diff --git a/test/shared/settings/Blacklist.test.ts b/test/shared/settings/Blacklist.test.ts index 0112757..dfd036e 100644 --- a/test/shared/settings/Blacklist.test.ts +++ b/test/shared/settings/Blacklist.test.ts @@ -5,13 +5,13 @@ import Key from '../../../src/shared/settings/Key'; describe('BlacklistItem', () => { describe('#fromJSON', () => { it('parses string pattern', () => { - let item = BlacklistItem.fromJSON('example.com'); + const item = BlacklistItem.fromJSON('example.com'); expect(item.pattern).to.equal('example.com'); expect(item.partial).to.be.false; }); it('parses partial blacklist item', () => { - let item = BlacklistItem.fromJSON({ url: 'example.com', keys: ['j', 'k']}); + const item = BlacklistItem.fromJSON({ url: 'example.com', keys: ['j', 'k']}); expect(item.pattern).to.equal('example.com'); expect(item.partial).to.be.true; expect(item.keys).to.deep.equal(['j', 'k']); @@ -20,12 +20,12 @@ describe('BlacklistItem', () => { describe('#matches', () => { it('matches by "*"', () => { - let item = BlacklistItem.fromJSON('*'); + const item = BlacklistItem.fromJSON('*'); expect(item.matches(new URL('https://github.com/abc'))).to.be.true; }); it('matches by hostname', () => { - let item = BlacklistItem.fromJSON('github.com'); + const item = BlacklistItem.fromJSON('github.com'); expect(item.matches(new URL('https://github.com'))).to.be.true; expect(item.matches(new URL('https://gist.github.com'))).to.be.false; expect(item.matches(new URL('https://github.com/ueokande'))).to.be.true; @@ -34,14 +34,14 @@ describe('BlacklistItem', () => { }); it('matches by hostname with wildcard', () => { - let item = BlacklistItem.fromJSON('*.github.com'); + const item = BlacklistItem.fromJSON('*.github.com'); expect(item.matches(new URL('https://github.com'))).to.be.false; expect(item.matches(new URL('https://gist.github.com'))).to.be.true; }); it('matches by path', () => { - let item = BlacklistItem.fromJSON('github.com/abc'); + const item = BlacklistItem.fromJSON('github.com/abc'); expect(item.matches(new URL('https://github.com/abc'))).to.be.true; expect(item.matches(new URL('https://github.com/abcdef'))).to.be.false; @@ -49,7 +49,7 @@ describe('BlacklistItem', () => { }); it('matches by path with wildcard', () => { - let item = BlacklistItem.fromJSON('github.com/abc*'); + const item = BlacklistItem.fromJSON('github.com/abc*'); expect(item.matches(new URL('https://github.com/abc'))).to.be.true; expect(item.matches(new URL('https://github.com/abcdef'))).to.be.true; @@ -57,14 +57,14 @@ describe('BlacklistItem', () => { }); it('matches address and port', () => { - let item = BlacklistItem.fromJSON('127.0.0.1:8888'); + const item = BlacklistItem.fromJSON('127.0.0.1:8888'); expect(item.matches(new URL('http://127.0.0.1:8888/'))).to.be.true; expect(item.matches(new URL('http://127.0.0.1:8888/hello'))).to.be.true; }); it('matches with partial blacklist', () => { - let item = BlacklistItem.fromJSON({ url: 'google.com', keys: ['j', 'k'] }); + const item = BlacklistItem.fromJSON({ url: 'google.com', keys: ['j', 'k'] }); expect(item.matches(new URL('https://google.com'))).to.be.true; expect(item.matches(new URL('https://yahoo.com'))).to.be.false; @@ -73,7 +73,7 @@ describe('BlacklistItem', () => { describe('#includesPartialKeys', () => { it('matches with partial keys', () => { - let item = BlacklistItem.fromJSON({url: 'google.com', keys: ['j', 'k', '<C-U>']}); + const item = BlacklistItem.fromJSON({url: 'google.com', keys: ['j', 'k', '<C-U>']}); expect(item.includeKey(new URL('http://google.com/maps'), Key.fromMapKey('j'))).to.be.true; expect(item.includeKey(new URL('http://google.com/maps'), Key.fromMapKey('<C-U>'))).to.be.true; @@ -87,14 +87,14 @@ describe('BlacklistItem', () => { describe('Blacklist', () => { describe('#fromJSON', () => { it('parses string list', () => { - let blacklist = Blacklist.fromJSON(['example.com', 'example.org']); + const blacklist = Blacklist.fromJSON(['example.com', 'example.org']); expect(blacklist.toJSON()).to.deep.equals([ 'example.com', 'example.org', ]); }); it('parses mixed blacklist', () => { - let blacklist = Blacklist.fromJSON([ + const blacklist = Blacklist.fromJSON([ { url: 'example.com', keys: ['j', 'k']}, 'example.org', ]); @@ -105,21 +105,21 @@ describe('Blacklist', () => { }); it('parses empty blacklist', () => { - let blacklist = Blacklist.fromJSON([]); + const blacklist = Blacklist.fromJSON([]); expect(blacklist.toJSON()).to.deep.equals([]); }); }); describe('#includesEntireBlacklist', () => { it('matches a url with entire blacklist', () => { - let blacklist = Blacklist.fromJSON(['google.com', '*.github.com']); + const blacklist = Blacklist.fromJSON(['google.com', '*.github.com']); expect(blacklist.includesEntireBlacklist(new URL('https://google.com'))).to.be.true; expect(blacklist.includesEntireBlacklist(new URL('https://github.com'))).to.be.false; expect(blacklist.includesEntireBlacklist(new URL('https://gist.github.com'))).to.be.true; }); it('does not matches with partial blacklist', () => { - let blacklist = Blacklist.fromJSON(['google.com', { url: 'yahoo.com', keys: ['j', 'k'] }]); + const blacklist = Blacklist.fromJSON(['google.com', { url: 'yahoo.com', keys: ['j', 'k'] }]); expect(blacklist.includesEntireBlacklist(new URL('https://google.com'))).to.be.true; expect(blacklist.includesEntireBlacklist(new URL('https://yahoo.com'))).to.be.false; }); @@ -127,7 +127,7 @@ describe('Blacklist', () => { describe('#includesKeys', () => { it('matches with entire blacklist or keys in the partial blacklist', () => { - let blacklist = Blacklist.fromJSON([ + const blacklist = Blacklist.fromJSON([ 'google.com', { url: 'github.com', keys: ['j', 'k'] }, ]); diff --git a/test/shared/settings/Key.test.ts b/test/shared/settings/Key.test.ts index 91a47f8..3a1c86e 100644 --- a/test/shared/settings/Key.test.ts +++ b/test/shared/settings/Key.test.ts @@ -4,7 +4,7 @@ import Key from '../../../src/shared/settings/Key'; describe("Key", () => { describe('fromMapKey', () => { it('return for X', () => { - let key = Key.fromMapKey('x'); + const key = Key.fromMapKey('x'); expect(key.key).to.equal('x'); expect(key.shift).to.be.false; expect(key.ctrl).to.be.false; @@ -13,7 +13,7 @@ describe("Key", () => { }); it('return for Shift+X', () => { - let key = Key.fromMapKey('X'); + const key = Key.fromMapKey('X'); expect(key.key).to.equal('X'); expect(key.shift).to.be.true; expect(key.ctrl).to.be.false; @@ -22,7 +22,7 @@ describe("Key", () => { }); it('return for Ctrl+X', () => { - let key = Key.fromMapKey('<C-X>'); + const key = Key.fromMapKey('<C-X>'); expect(key.key).to.equal('x'); expect(key.shift).to.be.false; expect(key.ctrl).to.be.true; @@ -31,7 +31,7 @@ describe("Key", () => { }); it('returns for Ctrl+Meta+X', () => { - let key = Key.fromMapKey('<C-M-X>'); + const key = Key.fromMapKey('<C-M-X>'); expect(key.key).to.equal('x'); expect(key.shift).to.be.false; expect(key.ctrl).to.be.true; @@ -40,7 +40,7 @@ describe("Key", () => { }); it('returns for Ctrl+Shift+x', () => { - let key = Key.fromMapKey('<C-S-x>'); + const key = Key.fromMapKey('<C-S-x>'); expect(key.key).to.equal('X'); expect(key.shift).to.be.true; expect(key.ctrl).to.be.true; @@ -49,7 +49,7 @@ describe("Key", () => { }); it('returns for Shift+Esc', () => { - let key = Key.fromMapKey('<S-Esc>'); + const key = Key.fromMapKey('<S-Esc>'); expect(key.key).to.equal('Esc'); expect(key.shift).to.be.true; expect(key.ctrl).to.be.false; @@ -58,7 +58,7 @@ describe("Key", () => { }); it('returns for Ctrl+Esc', () => { - let key = Key.fromMapKey('<C-Esc>'); + const key = Key.fromMapKey('<C-Esc>'); expect(key.key).to.equal('Esc'); expect(key.shift).to.be.false; expect(key.ctrl).to.be.true; @@ -67,7 +67,7 @@ describe("Key", () => { }); it('returns for Ctrl+Esc', () => { - let key = Key.fromMapKey('<C-Space>'); + const key = Key.fromMapKey('<C-Space>'); expect(key.key).to.equal('Space'); expect(key.shift).to.be.false; expect(key.ctrl).to.be.true; diff --git a/test/shared/settings/Keymaps.test.ts b/test/shared/settings/Keymaps.test.ts index 9e4109f..dcea6e4 100644 --- a/test/shared/settings/Keymaps.test.ts +++ b/test/shared/settings/Keymaps.test.ts @@ -4,12 +4,12 @@ import { expect } from 'chai'; describe('Keymaps', () => { describe('#valueOf', () => { it('returns empty object by empty settings', () => { - let keymaps = Keymaps.fromJSON({}).toJSON(); + const keymaps = Keymaps.fromJSON({}).toJSON(); expect(keymaps).to.be.empty; }); it('returns keymaps by valid settings', () => { - let keymaps = Keymaps.fromJSON({ + const keymaps = Keymaps.fromJSON({ k: { type: "scroll.vertically", count: -1 }, j: { type: "scroll.vertically", count: 1 }, }).toJSON(); @@ -27,7 +27,7 @@ describe('Keymaps', () => { describe('#combine', () => { it('returns combined keymaps', () => { - let keymaps = Keymaps.fromJSON({ + const keymaps = Keymaps.fromJSON({ k: { type: "scroll.vertically", count: -1 }, j: { type: "scroll.vertically", count: 1 }, }).combine(Keymaps.fromJSON({ @@ -35,7 +35,7 @@ describe('Keymaps', () => { N: { type: "find.prev" }, })); - let entries = keymaps.entries().sort(([name1], [name2]) => name1.localeCompare(name2)); + const entries = keymaps.entries().sort(([name1], [name2]) => name1.localeCompare(name2)); expect(entries).deep.equals([ ['j', { type: "scroll.vertically", count: 1 }], ['k', { type: "scroll.vertically", count: -1 }], @@ -45,7 +45,7 @@ describe('Keymaps', () => { }); it('overrides current keymaps', () => { - let keymaps = Keymaps.fromJSON({ + const keymaps = Keymaps.fromJSON({ k: { type: "scroll.vertically", count: -1 }, j: { type: "scroll.vertically", count: 1 }, }).combine(Keymaps.fromJSON({ @@ -53,7 +53,7 @@ describe('Keymaps', () => { j: { type: "find.prev" }, })); - let entries = keymaps.entries().sort(([name1], [name2]) => name1.localeCompare(name2)); + const entries = keymaps.entries().sort(([name1], [name2]) => name1.localeCompare(name2)); expect(entries).deep.equals([ ['j', { type: "find.prev" }], ['k', { type: "scroll.vertically", count: -1 }], diff --git a/test/shared/settings/Properties.test.ts b/test/shared/settings/Properties.test.ts index 609a565..4639839 100644 --- a/test/shared/settings/Properties.test.ts +++ b/test/shared/settings/Properties.test.ts @@ -4,7 +4,7 @@ import { expect } from 'chai'; describe('Properties', () => { describe('#propertiesValueOf', () => { it('returns with default properties by empty settings', () => { - let props = Properties.fromJSON({}); + const props = Properties.fromJSON({}); expect(props).to.deep.equal({ hintchars: "abcdefghijklmnopqrstuvwxyz", smoothscroll: false, @@ -13,7 +13,7 @@ describe('Properties', () => { }); it('returns properties by valid settings', () => { - let props = Properties.fromJSON({ + const props = Properties.fromJSON({ hintchars: "abcdefgh", smoothscroll: false, complete: "sbh" diff --git a/test/shared/settings/Search.test.ts b/test/shared/settings/Search.test.ts index 51cd3eb..8bd8d89 100644 --- a/test/shared/settings/Search.test.ts +++ b/test/shared/settings/Search.test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; describe('Search', () => { it('returns search settings by valid settings', () => { - let search = Search.fromJSON({ + const search = Search.fromJSON({ default: 'google', engines: { 'google': 'https://google.com/search?q={}', diff --git a/test/shared/settings/Settings.test.ts b/test/shared/settings/Settings.test.ts index ab6af04..658132c 100644 --- a/test/shared/settings/Settings.test.ts +++ b/test/shared/settings/Settings.test.ts @@ -4,7 +4,7 @@ import { expect } from 'chai'; describe('Settings', () => { describe('#valueOf', () => { it('returns settings by valid settings', () => { - let x = Settings.fromJSON({ + const x = Settings.fromJSON({ keymaps: {}, "search": { "default": "google", @@ -39,7 +39,7 @@ describe('Settings', () => { }); it('sets default settings', () => { - let value = Settings.fromJSON({}); + const 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'); |