Skip to content

Commit

Permalink
Revert "Remove path.join as glob library handles"
Browse files Browse the repository at this point in the history
This reverts commit f6898e3.
  • Loading branch information
kmturley committed Oct 14, 2023
1 parent f6898e3 commit b0b0da2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
9 changes: 5 additions & 4 deletions tests/convert.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path';
import {
convertJsToSfz,
convertJsToXml,
Expand All @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions tests/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tests/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ 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'));
expect(convertToXml(await parseSfz(sfzText, syntaxDir))).toEqual(sfzXml);
});

// 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'));
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit b0b0da2

Please sign in to comment.