diff --git a/tests/convert.test.ts b/tests/convert.test.ts index 2cdb804..4d3fde9 100644 --- a/tests/convert.test.ts +++ b/tests/convert.test.ts @@ -1,3 +1,4 @@ +import path from 'path'; import { convertJsToSfz, convertJsToXml, @@ -9,10 +10,10 @@ import { import { fileReadJson, fileReadString } from '../dist/file'; import { ParseDefinition } from '../dist/types/parse'; -const syntaxDir: string = 'test/syntax'; -const sfzJs: ParseDefinition = fileReadJson(`${syntaxDir}/basic.json`); -const sfzText: string = fileReadString(`${syntaxDir}/basic.sfz`); -const sfzXml: string = fileReadString(`${syntaxDir}/basic.xml`); +const syntaxDir: string = path.join('test', 'syntax'); +const sfzJs: ParseDefinition = fileReadJson(path.join(syntaxDir, 'basic.json')); +const sfzText: string = fileReadString(path.join(syntaxDir, 'basic.sfz')); +const sfzXml: string = fileReadString(path.join(syntaxDir, 'basic.xml')); test('Convert Js to Sfz', async () => { expect(await convertJsToSfz(sfzJs)).toEqual(sfzText); diff --git a/tests/file.test.ts b/tests/file.test.ts index 4c93095..4f85159 100644 --- a/tests/file.test.ts +++ b/tests/file.test.ts @@ -18,12 +18,14 @@ import { fileOpen, fileSize, } from '../src/file'; +import os from 'os'; +import path from 'path'; -const DIR_PATH: string = 'test/new-directory'; -const DIR_PATH_GLOB: string = `${DIR_PATH}/**/*.txt`; -const DIR_RENAME: string = 'test/new-directory-renamed'; +const DIR_PATH: string = path.join('test', 'new-directory'); +const DIR_PATH_GLOB: string = path.join('test', 'new-directory', '**', '*.txt'); +const DIR_RENAME: string = path.join('test', 'new-directory-renamed'); -const FILE_PATH: string = `${DIR_PATH}/file.txt`; +const FILE_PATH: string = path.join('test', 'new-directory', 'file.txt'); test('Directory contains', () => { expect(dirContains('test', DIR_PATH)).toEqual(true); diff --git a/tests/parse.test.ts b/tests/parse.test.ts index 9e4f384..51bb3a8 100644 --- a/tests/parse.test.ts +++ b/tests/parse.test.ts @@ -31,8 +31,8 @@ function convertToXml(elements: any) { } // Test specific syntax edge-cases -const syntaxDir: string = 'test/syntax'; -const syntaxTests: string[] = dirRead(`${syntaxDir}/**/*.sfz`); +const syntaxDir: string = path.join('test', 'syntax'); +const syntaxTests: string[] = dirRead(path.join(syntaxDir, '**', '*.sfz')); test.each(syntaxTests)('parseSfz %p', async (sfzFile: string) => { const sfzText: string = fileReadString(sfzFile); const sfzXml: string = fileReadString(sfzFile.replace('.sfz', '.xml')); @@ -40,8 +40,8 @@ test.each(syntaxTests)('parseSfz %p', async (sfzFile: string) => { }); // Test entire sfz test suite -const sfzDir: string = 'sfz-tests'; -const sfzTests: string[] = dirRead(`${sfzDir}/**/*.sfz`); +const sfzDir: string = path.join('sfz-tests'); +const sfzTests: string[] = dirRead(path.join(sfzDir, '**', '*.sfz')); test.each(sfzTests)('parseSfz %p', async (sfzFile: string) => { const sfzText: string = fileReadString(sfzFile); const sfzXml: string = fileReadString(sfzFile.replace('.sfz', '.xml')); diff --git a/tests/utils.test.ts b/tests/utils.test.ts index c28b5d3..4a247e4 100644 --- a/tests/utils.test.ts +++ b/tests/utils.test.ts @@ -4,10 +4,10 @@ import { pathGetDirectory, pathGetExt, pathGetFilename, pathJoin } from '../src/ const FILE_EXT: string = 'txt'; const FILE_NAME: string = 'filename'; const FILE_NAME_EXT: string = `${FILE_NAME}.${FILE_EXT}`; -const FILE_PATH = `foldera/folderb/${FILE_NAME_EXT}`; +const FILE_PATH = path.join('foldera', 'folderb', FILE_NAME_EXT); test('Path get directory', () => { - expect(pathGetDirectory(FILE_PATH, path.sep)).toEqual('foldera/folderb'); + expect(pathGetDirectory(FILE_PATH, path.sep)).toEqual(path.join('foldera', 'folderb')); }); test('Path get extension', () => {