From 029d5365e7d74e87375fccb8db097b7c2df3f7f4 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 22 Dec 2019 10:28:14 +0900 Subject: npm run lint:fix --- test/content/presenters/Hint.test.ts | 48 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'test/content/presenters/Hint.test.ts') 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(); }); }); -- cgit v1.2.3 From da72c2ddd916d79d134662e3985b53a4ac78af7a Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 22 Dec 2019 10:42:48 +0900 Subject: Fix lint rules on tests --- .eslintrc | 1 + test/background/repositories/Mark.test.ts | 5 ++--- test/console/components/console/Completion.test.tsx | 2 -- test/content/InputDriver.test.ts | 2 +- test/content/presenters/Hint.test.ts | 2 +- test/content/presenters/NavigationPresenter.test.ts | 7 +++---- test/content/repositories/KeymapRepository.test.ts | 10 +++++----- test/content/usecases/ClipboardUseCase.test.ts | 20 ++++++++++++++++---- test/main.ts | 6 ++---- 9 files changed, 31 insertions(+), 24 deletions(-) (limited to 'test/content/presenters/Hint.test.ts') diff --git a/.eslintrc b/.eslintrc index 0ff0b11..d08c3a6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -28,6 +28,7 @@ }, "rules": { "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/no-empty-function": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-namespace": "off", "@typescript-eslint/no-non-null-assertion": "off", diff --git a/test/background/repositories/Mark.test.ts b/test/background/repositories/Mark.test.ts index 625f11d..ed1a68e 100644 --- a/test/background/repositories/Mark.test.ts +++ b/test/background/repositories/Mark.test.ts @@ -1,11 +1,10 @@ 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() => { diff --git a/test/console/components/console/Completion.test.tsx b/test/console/components/console/Completion.test.tsx index a271d77..e411c4a 100644 --- a/test/console/components/console/Completion.test.tsx +++ b/test/console/components/console/Completion.test.tsx @@ -84,7 +84,6 @@ describe("console/components/console/completion", () => { size={3} select={1} />); - const instance = component.getInstance(); const root = component.root; let children = root.children[0].children; @@ -127,7 +126,6 @@ describe("console/components/console/completion", () => { select={5} />); const root = component.root; - const instance = component.getInstance(); let children = root.children[0].children; expect(children).to.have.lengthOf(3); diff --git a/test/content/InputDriver.test.ts b/test/content/InputDriver.test.ts index 367ec1d..d3a55dd 100644 --- a/test/content/InputDriver.test.ts +++ b/test/content/InputDriver.test.ts @@ -104,7 +104,7 @@ describe('InputDriver', () => { ['input', 'textarea', 'select'].forEach((name) => { const input = window.document.createElement(name); const driver = new InputDriver(input); - driver.onKey((key: Key): boolean => { + driver.onKey((_key: Key): boolean => { expect.fail(); return false; }); diff --git a/test/content/presenters/Hint.test.ts b/test/content/presenters/Hint.test.ts index 708ddaa..7daa63d 100644 --- a/test/content/presenters/Hint.test.ts +++ b/test/content/presenters/Hint.test.ts @@ -12,7 +12,7 @@ describe('Hint', () => { describe('#constructor', () => { it('creates a hint element with tag name', () => { const link = document.getElementById('test-link'); - const hint = new Hint(link, 'abc'); + new Hint(link, 'abc'); const elem = document.querySelector('.vimvixen-hint'); expect(elem.textContent.trim()).to.be.equal('abc'); 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/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/usecases/ClipboardUseCase.test.ts b/test/content/usecases/ClipboardUseCase.test.ts index 2e711c6..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(() => { - const modal = {}; + clipboardRepository = new class implements ClipboardRepository { + read(): string { return ""; } + write(_text: string) {} + }; + operationClient = new class implements OperationClient { + execBackgroundOp(_repeat: number, _op: Operation): Promise { return Promise.resolve() } + internalOpenUrl(_url: string, _newTab?: boolean, _background?: boolean): Promise { return Promise.resolve() } + }; + consoleClient = new class implements ConsoleClient { + error(_text: string): Promise { return Promise.resolve() } + info(_text: string): Promise { return Promise.resolve() } + }; - clipboardRepository = { read() {}, write(_) {} }; - operationClient = { internalOpenUrl(_) {} }; - consoleClient = { info(_) {}}; sut = new ClipboardUseCase( clipboardRepository, new SettingRepositoryImpl(), 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(); -- cgit v1.2.3