Skip to content

Commit

Permalink
Ensure fixture path is created before used in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mjacobus committed Sep 22, 2023
1 parent 081be9d commit 8750c39
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/MediaFiles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ const MediaFiles = require("../src/MediaFiles");
const MediaFile = require("../src/MediaFile");
const fs = require("fs");

function baseDir(path) {
return path.split("/").slice(0, -1).join("/");
}

function fixturePath(filename) {
const testFilePath = __filename;
const dir = testFilePath.split("/").slice(0, -1).join("/");
const dir = baseDir(__filename);
return `${dir}/fixtures/${filename}`;
}

function tmpPath(file) {
const testFilePath = __filename;
const dir = testFilePath.split("/").slice(0, -1).join("/");
return `${dir}/tmp/${file}`;
const dir = baseDir(__filename);
file = `${dir}/tmp/${file}`;
fs.mkdirSync(baseDir(file), { recursive: true });
return file;
}

const createFile = (id, data = {}) => ({ ...data, id });
Expand Down

0 comments on commit 8750c39

Please sign in to comment.