diff options
| author | Oskar <oskar@mullvad.net> | 2024-09-20 16:29:26 +0200 |
|---|---|---|
| committer | Oskar <oskar@mullvad.net> | 2024-09-24 13:18:18 +0200 |
| commit | 4bb25616f02af4e15b0140767c07b61e49e8aa83 (patch) | |
| tree | ed5371911d23ba2bab8e701f351d822202d63d57 /gui/test/unit | |
| parent | 659aa11f05ae2b278eef6ab0ef5bc537e756109a (diff) | |
| download | mullvadvpn-4bb25616f02af4e15b0140767c07b61e49e8aa83.tar.xz mullvadvpn-4bb25616f02af4e15b0140767c07b61e49e8aa83.zip | |
Fix linting errors
Diffstat (limited to 'gui/test/unit')
| -rw-r--r-- | gui/test/unit/account-data-cache.spec.ts | 15 | ||||
| -rw-r--r-- | gui/test/unit/changelog.spec.ts | 3 | ||||
| -rw-r--r-- | gui/test/unit/date-helper.spec.ts | 88 | ||||
| -rw-r--r-- | gui/test/unit/history.spec.ts | 3 | ||||
| -rw-r--r-- | gui/test/unit/ip.spec.ts | 3 | ||||
| -rw-r--r-- | gui/test/unit/keyframe-animation.spec.ts | 3 | ||||
| -rw-r--r-- | gui/test/unit/list-diff.spec.ts | 3 | ||||
| -rw-r--r-- | gui/test/unit/logging.spec.ts | 7 | ||||
| -rw-r--r-- | gui/test/unit/notification-evaluation.spec.ts | 36 | ||||
| -rw-r--r-- | gui/test/unit/setup.ts | 2 | ||||
| -rw-r--r-- | gui/test/unit/tunnel-state.spec.ts | 4 |
11 files changed, 84 insertions, 83 deletions
diff --git a/gui/test/unit/account-data-cache.spec.ts b/gui/test/unit/account-data-cache.spec.ts index f3d6df3142..cf1c4299d8 100644 --- a/gui/test/unit/account-data-cache.spec.ts +++ b/gui/test/unit/account-data-cache.spec.ts @@ -1,7 +1,8 @@ +import { expect, spy } from 'chai'; +import sinon from 'sinon'; + import AccountDataCache, { AccountFetchError } from '../../src/main/account-data-cache'; import { AccountDataResponse, IAccountData } from '../../src/shared/daemon-rpc-types'; -import sinon from 'sinon'; -import { expect, spy } from 'chai'; describe('IAccountData cache', () => { const dummyAccountToken = '9876543210'; @@ -44,7 +45,7 @@ describe('IAccountData cache', () => { const watcher = new Promise<void>((resolve, reject) => { cache.fetch(dummyAccountToken, { - onFinish: (_reason?: any) => resolve(), + onFinish: () => resolve(), onError: (_error: AccountFetchError) => reject(), }); }); @@ -254,9 +255,7 @@ describe('IAccountData cache', () => { await new Promise((resolve) => setTimeout(resolve)); cache.fetch(dummyAccountToken, { - onFinish: async () => { - resolve(); - }, + onFinish: () => resolve(), onError: (_error: AccountFetchError) => reject(), }); }, @@ -298,9 +297,7 @@ describe('IAccountData cache', () => { await new Promise((resolve) => setTimeout(resolve)); cache.fetch(dummyAccountToken, { - onFinish: async () => { - resolve(); - }, + onFinish: () => resolve(), onError: (_error: AccountFetchError) => reject(), }); }, diff --git a/gui/test/unit/changelog.spec.ts b/gui/test/unit/changelog.spec.ts index 249c26e1db..774dca956b 100644 --- a/gui/test/unit/changelog.spec.ts +++ b/gui/test/unit/changelog.spec.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; -import { after, it, describe } from 'mocha'; +import { after, describe, it } from 'mocha'; + import { parseChangelog } from '../../src/main/changelog'; // It should be handled the same no matter if the platforms are split with a space or not. diff --git a/gui/test/unit/date-helper.spec.ts b/gui/test/unit/date-helper.spec.ts index 74500ff960..82c4faeac7 100644 --- a/gui/test/unit/date-helper.spec.ts +++ b/gui/test/unit/date-helper.spec.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; -import { it, describe } from 'mocha'; +import { describe, it } from 'mocha'; + import * as date from '../../src/shared/date-helper'; describe('Date helper', () => { @@ -100,76 +101,61 @@ describe('Date helper', () => { }); it('should format positive difference as string', () => { - const diff1 = date.formatRelativeDate( - '2021-01-01 13:37:10', - '2021-01-01 13:37:20', - { displayMonths: true }, - ); + const diff1 = date.formatRelativeDate('2021-01-01 13:37:10', '2021-01-01 13:37:20', { + displayMonths: true, + }); expect(diff1).to.equal('less than a day'); - const diff2 = date.formatRelativeDate( - '2021-01-01 13:37:10', - '2021-01-02 13:37:20', - { displayMonths: true }, - ); + const diff2 = date.formatRelativeDate('2021-01-01 13:37:10', '2021-01-02 13:37:20', { + displayMonths: true, + }); expect(diff2).to.equal('1 day'); - const diff3 = date.formatRelativeDate( - '2021-01-01 13:37:10', - '2021-02-25 13:37:20', - { displayMonths: true }, - ); + const diff3 = date.formatRelativeDate('2021-01-01 13:37:10', '2021-02-25 13:37:20', { + displayMonths: true, + }); expect(diff3).to.equal('55 days'); - const diff4 = date.formatRelativeDate( - '2021-01-01 13:37:10', - '2021-04-25 13:37:20', - { displayMonths: true }, - ); + const diff4 = date.formatRelativeDate('2021-01-01 13:37:10', '2021-04-25 13:37:20', { + displayMonths: true, + }); expect(diff4).to.equal('3 months'); - const diff5 = date.formatRelativeDate( - '2021-01-01 13:37:10', - '2031-04-25 13:37:20', - { displayMonths: true }, - ); + const diff5 = date.formatRelativeDate('2021-01-01 13:37:10', '2031-04-25 13:37:20', { + displayMonths: true, + }); expect(diff5).to.equal('10 years'); }); it('should format positive difference as string suffixed with "left"', () => { - const diff1 = date.formatRelativeDate( - '2021-01-01 13:37:10', - '2021-01-01 13:37:20', - { suffix: true, displayMonths: true }, - ); + const diff1 = date.formatRelativeDate('2021-01-01 13:37:10', '2021-01-01 13:37:20', { + suffix: true, + displayMonths: true, + }); expect(diff1).to.equal('less than a day left'); - const diff2 = date.formatRelativeDate( - '2021-01-01 13:37:10', - '2021-01-02 13:37:20', - { suffix: true, displayMonths: true }, - ); + const diff2 = date.formatRelativeDate('2021-01-01 13:37:10', '2021-01-02 13:37:20', { + suffix: true, + displayMonths: true, + }); expect(diff2).to.equal('1 day left'); - const diff3 = date.formatRelativeDate( - '2021-01-01 13:37:10', - '2021-02-25 13:37:20', - { suffix: true, displayMonths: true }, - ); + const diff3 = date.formatRelativeDate('2021-01-01 13:37:10', '2021-02-25 13:37:20', { + suffix: true, + displayMonths: true, + }); expect(diff3).to.equal('55 days left'); - const diff4 = date.formatRelativeDate( - '2021-01-01 13:37:10', - '2021-04-25 13:37:20', - { suffix: true, displayMonths: true }, - ); + const diff4 = date.formatRelativeDate('2021-01-01 13:37:10', '2021-04-25 13:37:20', { + suffix: true, + displayMonths: true, + }); expect(diff4).to.equal('3 months left'); - const diff5 = date.formatRelativeDate( - '2021-01-01 13:37:10', - '2031-04-25 13:37:20', - { suffix: true, displayMonths: true }, - ); + const diff5 = date.formatRelativeDate('2021-01-01 13:37:10', '2031-04-25 13:37:20', { + suffix: true, + displayMonths: true, + }); expect(diff5).to.equal('10 years left'); }); diff --git a/gui/test/unit/history.spec.ts b/gui/test/unit/history.spec.ts index 03eabd80cc..739c65c5ca 100644 --- a/gui/test/unit/history.spec.ts +++ b/gui/test/unit/history.spec.ts @@ -1,5 +1,6 @@ import { expect, spy } from 'chai'; -import { it, describe, beforeEach } from 'mocha'; +import { beforeEach, describe, it } from 'mocha'; + import History from '../../src/renderer/lib/history'; import { RoutePath } from '../../src/renderer/lib/routes'; diff --git a/gui/test/unit/ip.spec.ts b/gui/test/unit/ip.spec.ts index 10b93bc890..5f6a265d25 100644 --- a/gui/test/unit/ip.spec.ts +++ b/gui/test/unit/ip.spec.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; -import { it, describe } from 'mocha'; +import { describe, it } from 'mocha'; + import * as ip from '../../src/renderer/lib/ip'; const validIpv4Addresses = [ diff --git a/gui/test/unit/keyframe-animation.spec.ts b/gui/test/unit/keyframe-animation.spec.ts index 59b5c2d6f7..0ba302e65c 100644 --- a/gui/test/unit/keyframe-animation.spec.ts +++ b/gui/test/unit/keyframe-animation.spec.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; -import { it, describe } from 'mocha'; +import { describe, it } from 'mocha'; + import KeyframeAnimation from '../../src/main/keyframe-animation'; describe('lib/keyframe-animation', function () { diff --git a/gui/test/unit/list-diff.spec.ts b/gui/test/unit/list-diff.spec.ts index 9357579072..e64d79b193 100644 --- a/gui/test/unit/list-diff.spec.ts +++ b/gui/test/unit/list-diff.spec.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; -import { it, describe } from 'mocha'; +import { describe, it } from 'mocha'; + import { calculateItemList, RowDisplayData } from '../../src/renderer/components/List'; const prevItems: Array<RowDisplayData<undefined>> = [ diff --git a/gui/test/unit/logging.spec.ts b/gui/test/unit/logging.spec.ts index d107a23d3b..393b631ba5 100644 --- a/gui/test/unit/logging.spec.ts +++ b/gui/test/unit/logging.spec.ts @@ -1,10 +1,11 @@ import { expect, spy } from 'chai'; import fs from 'fs'; -import sinon from 'sinon'; -import { it, describe, before, beforeEach, after } from 'mocha'; +import { after, before, beforeEach, describe, it } from 'mocha'; import path from 'path'; -import { Logger } from '../../src/shared/logging'; +import sinon from 'sinon'; + import { backupLogFile, rotateOrDeleteFile } from '../../src/main/logging'; +import { Logger } from '../../src/shared/logging'; import { LogLevel } from '../../src/shared/logging-types'; const aPath = path.normalize('log-directory/a.log'); diff --git a/gui/test/unit/notification-evaluation.spec.ts b/gui/test/unit/notification-evaluation.spec.ts index 27de83cf29..723307b3d7 100644 --- a/gui/test/unit/notification-evaluation.spec.ts +++ b/gui/test/unit/notification-evaluation.spec.ts @@ -1,21 +1,25 @@ import { expect } from 'chai'; -import { it, describe } from 'mocha'; +import { describe, it } from 'mocha'; import sinon from 'sinon'; -import { - UnsupportedVersionNotificationProvider, - UpdateAvailableNotificationProvider, -} from '../../src/shared/notifications/notification'; import NotificationController from '../../src/main/notification-controller'; import { TunnelState } from '../../src/shared/daemon-rpc-types'; import { ErrorStateCause } from '../../src/shared/daemon-rpc-types'; import { FirewallPolicyErrorType } from '../../src/shared/daemon-rpc-types'; +import { + UnsupportedVersionNotificationProvider, + UpdateAvailableNotificationProvider, +} from '../../src/shared/notifications/notification'; function createController() { return new NotificationController({ - openApp: () => { /* no-op */ }, + openApp: () => { + /* no-op */ + }, openLink: (_url: string, _withAuth?: boolean) => Promise.resolve(), - showNotificationIcon: (_value: boolean) => { /* no-op */ }, + showNotificationIcon: (_value: boolean) => { + /* no-op */ + }, }); } @@ -26,10 +30,18 @@ describe('System notifications', () => { sandbox = sinon.createSandbox(); // @ts-ignore sandbox.stub(NotificationController.prototype, 'createElectronNotification').returns({ - show: () => { /* no-op */ }, - close: () => { /* no-op */ }, - on: () => { /* no-op */ }, - removeAllListeners: () => { /* no-op */ }, + show: () => { + /* no-op */ + }, + close: () => { + /* no-op */ + }, + on: () => { + /* no-op */ + }, + removeAllListeners: () => { + /* no-op */ + }, }); }); @@ -133,7 +145,7 @@ describe('System notifications', () => { cause: ErrorStateCause.isOffline, blockingError: { type: FirewallPolicyErrorType.generic, - } + }, }, }; const result6 = controller.notifyTunnelState(nonBlockingErrorState, false, false, false, false); diff --git a/gui/test/unit/setup.ts b/gui/test/unit/setup.ts index 65644e28d9..a565ec50ca 100644 --- a/gui/test/unit/setup.ts +++ b/gui/test/unit/setup.ts @@ -1,6 +1,6 @@ import chai from 'chai'; -import spies from 'chai-spies'; import chaiAsPromised from 'chai-as-promised'; +import spies from 'chai-spies'; chai.use(spies); chai.use(chaiAsPromised); diff --git a/gui/test/unit/tunnel-state.spec.ts b/gui/test/unit/tunnel-state.spec.ts index d4629ebc64..a6013523b8 100644 --- a/gui/test/unit/tunnel-state.spec.ts +++ b/gui/test/unit/tunnel-state.spec.ts @@ -1,6 +1,7 @@ import { expect, spy } from 'chai'; -import { it, describe } from 'mocha'; +import { describe, it } from 'mocha'; import sinon from 'sinon'; + import TunnelStateHandler from '../../src/main/tunnel-state'; import { TunnelState } from '../../src/shared/daemon-rpc-types'; @@ -106,4 +107,3 @@ describe('Tunnel state', () => { clock.restore(); }); }); - |
