From 0b14b68a92d3d5cf5f863f094ee198ea4e4df8bb Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Fri, 17 Jun 2022 12:48:11 -0400 Subject: [PATCH] Skip version outdated test when versions are equal --- src/__helpers__/it-if.ts | 9 +++++++++ .../__tests__/recommended-server-discovery.test.ts | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/__helpers__/it-if.ts diff --git a/src/__helpers__/it-if.ts b/src/__helpers__/it-if.ts new file mode 100644 index 000000000..16cfd8ff0 --- /dev/null +++ b/src/__helpers__/it-if.ts @@ -0,0 +1,9 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +export function itIf(condition: boolean, ...args: [string, jest.ProvidesCallback?, number?]): void { + return condition ? test(...args) : test.skip(...args); +} diff --git a/src/discovery/__tests__/recommended-server-discovery.test.ts b/src/discovery/__tests__/recommended-server-discovery.test.ts index 529a8876a..b7f3864c4 100644 --- a/src/discovery/__tests__/recommended-server-discovery.test.ts +++ b/src/discovery/__tests__/recommended-server-discovery.test.ts @@ -10,6 +10,7 @@ import { mocked } from 'ts-jest/utils'; import { RecommendedServerDiscovery } from '..'; import { API_VERSION, Jellyfin, MINIMUM_VERSION, ProductNameIssue, RecommendedServerInfoScore, SlowResponseIssue, SystemInfoIssue, VersionMissingIssue, VersionOutdatedIssue, VersionUnsupportedIssue } from '../..'; import { TEST_CLIENT, TEST_DEVICE } from '../../__helpers__/common'; +import { itIf } from '../../__helpers__/it-if'; jest.mock('axios'); const mockAxios = mocked(axios, true); @@ -64,7 +65,9 @@ describe('RecommendedServerDiscovery', () => { expect(info.systemInfo).toBe(systemInfo); }); - it('should return an issue for outdated versions', async () => { + /* eslint-disable jest/no-standalone-expect */ + // NOTE: This test will only work if API_VERSION and MINIMUM_VERSION are not the same! + itIf(API_VERSION !== MINIMUM_VERSION, 'should return an issue for outdated versions', async () => { const serverDiscovery = new RecommendedServerDiscovery(SDK_INSTANCE); const systemInfo = { Version: MINIMUM_VERSION, @@ -81,6 +84,7 @@ describe('RecommendedServerDiscovery', () => { expect(info.score).toBe(RecommendedServerInfoScore.GOOD); expect(info.systemInfo).toBe(systemInfo); }); + /* eslint-enable jest/no-standalone-expect */ it('should return an issue for slow responses', async () => { const serverDiscovery = new RecommendedServerDiscovery(SDK_INSTANCE);