diff --git a/server/services/taxonomyService.test.ts b/server/services/taxonomyService.test.ts index b37084fe6..541be19bc 100644 --- a/server/services/taxonomyService.test.ts +++ b/server/services/taxonomyService.test.ts @@ -35,6 +35,7 @@ const toTreeNodes = (locations: LocationRecord, separator: string = '/', basePat describe('taxonomyService', () => { describe('incrementLocationCountsAndSizes() - locationTree', () => { + // describe('#linux', () => { for (let locationsAndExpected of [ // No torrents {locations: [] as string[], expected: toTreeNodes({'': null})[0]}, @@ -63,15 +64,19 @@ describe('taxonomyService', () => { it(`builds Linux-style case-sensitive location tree correctly from ${locations}`, () => { const taxonomyService = new TaxonomyService({} as UserInDatabase); - const spy = jest.spyOn(os, 'type'); - spy.mockReturnValue('Linux'); + const mock = jest.spyOn(os, 'platform'); + mock.mockImplementation(() => 'linux'); for (let location of locations) taxonomyService.incrementLocationCountsAndSizes(location, 10); expect(taxonomyService.taxonomy.locationTree).toMatchObject(expected); + + mock.mockRestore(); }); } + // }); + // describe('#mac', () => { for (let locationsAndExpected of [ // Multiple roots including overlapping case { @@ -88,13 +93,16 @@ describe('taxonomyService', () => { it(`builds Mac-style case-insensitive location tree correctly from ${locations}`, () => { const taxonomyService = new TaxonomyService({} as UserInDatabase); - const spy = jest.spyOn(os, 'type'); - spy.mockReturnValue('Darwin'); + const mock = jest.spyOn(os, 'platform'); + mock.mockImplementation(() => 'darwin'); for (let location of locations) taxonomyService.incrementLocationCountsAndSizes(location, 10); expect(taxonomyService.taxonomy.locationTree).toMatchObject(expected); + + mock.mockRestore(); }); } + // }); }); }); diff --git a/server/util/fileUtil.ts b/server/util/fileUtil.ts index 3dc56014e..e7b010354 100644 --- a/server/util/fileUtil.ts +++ b/server/util/fileUtil.ts @@ -1,6 +1,6 @@ import fs from 'fs'; import {promises as fsp} from 'fs'; -import os, {homedir} from 'os'; +import {homedir, platform} from 'os'; import path from 'path'; import config from '../../config'; @@ -89,4 +89,4 @@ export const sanitizePath = (input?: string): string => { return path.resolve(input.replace(/^~/, homedir()).replace(controlRe, '')); }; -export const isInsensitiveOs = (): boolean => ['Windows_NT'].includes(os.type()); +export const isInsensitiveOs = (): boolean => ['darwin', 'win32'].includes(platform());