diff options
Diffstat (limited to 'test/content')
-rw-r--r-- | test/content/InputDriver.test.ts | 20 | ||||
-rw-r--r-- | test/content/domains/KeySequence.test.ts | 16 | ||||
-rw-r--r-- | test/content/presenters/Hint.test.ts | 48 | ||||
-rw-r--r-- | test/content/repositories/AddonEnabledRepository.test.ts | 2 | ||||
-rw-r--r-- | test/content/repositories/FindRepository.test.ts | 2 | ||||
-rw-r--r-- | test/content/repositories/FollowMasterRepository.test.ts | 2 | ||||
-rw-r--r-- | test/content/repositories/MarkRepository.test.ts | 2 | ||||
-rw-r--r-- | test/content/repositories/SettingRepository.test.ts | 6 | ||||
-rw-r--r-- | test/content/usecases/ClipboardUseCase.test.ts | 18 | ||||
-rw-r--r-- | test/content/usecases/FindUseCase.test.ts | 2 | ||||
-rw-r--r-- | test/content/usecases/HintKeyProducer.test.ts | 6 | ||||
-rw-r--r-- | test/content/usecases/KeymapUseCase.test.ts | 10 | ||||
-rw-r--r-- | test/content/usecases/SettingUseCaase.test.ts | 6 |
13 files changed, 70 insertions, 70 deletions
diff --git a/test/content/InputDriver.test.ts b/test/content/InputDriver.test.ts index 441d107..367ec1d 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,8 +102,8 @@ describe('InputDriver', () => { it('ignores events from input elements', () => { ['input', 'textarea', 'select'].forEach((name) => { - let input = window.document.createElement(name); - let driver = new InputDriver(input); + 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..708ddaa 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'); + const hint = 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/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/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..2e711c6 100644 --- a/test/content/usecases/ClipboardUseCase.test.ts +++ b/test/content/usecases/ClipboardUseCase.test.ts @@ -14,7 +14,7 @@ describe('ClipboardUseCase', () => { let sut: ClipboardUseCase; beforeEach(() => { - var modal = <ConsoleClient>{}; + const modal = <ConsoleClient>{}; clipboardRepository = <ClipboardRepository>{ read() {}, write(_) {} }; operationClient = <OperationClient>{ internalOpenUrl(_) {} }; @@ -29,13 +29,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 +45,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 +56,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'); }); }); |