Skip to content

Commit

Permalink
Skip version outdated test when versions are equal
Browse files Browse the repository at this point in the history
  • Loading branch information
thornbill committed Jun 17, 2022
1 parent a182e96 commit 0b14b68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/__helpers__/it-if.ts
Original file line number Diff line number Diff line change
@@ -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);
}
6 changes: 5 additions & 1 deletion src/discovery/__tests__/recommended-server-discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit 0b14b68

Please sign in to comment.