@applicaster/zapplicaster-cli
Version:
CLI Tool for the zapp app and Quick Brick project
60 lines (50 loc) • 1.52 kB
JavaScript
import {
cwd,
quickBrickTemplate,
quickBrickDirectory,
getFileDestinationPath,
} from "../paths";
import { join } from "path";
jest.mock("path", () => ({
...jest.requireActual("path"),
resolve: (...args) => args.join("/"),
}));
describe("paths.cwd", () => {
it("returns the current working directory", () => {
expect(cwd).toBe(process.cwd());
});
});
describe("quickBrickTemplate", () => {
it("returns the path of the quickBrickTemplate", () => {
expect(quickBrickTemplate).toBe(join(__dirname, "../../templates"));
});
});
describe("quickBrickDirectory", () => {
describe("when an argument is provided", () => {
it("returns that path", () => {
const path = join(__dirname, "..");
expect(quickBrickDirectory(path)).toBe(path);
});
});
describe("when no argument is provided", () => {
it("returns the path of cwd/quick_brick", () => {
expect(quickBrickDirectory()).toBe(join(cwd, "./quick_brick"));
});
});
});
describe("getFileDestinationPath", () => {
const destinationPath = "path/to/app";
const platform = "ios";
const folder = "config";
const fileName = "file.json";
it("returns the destination path for the given folder", () => {
expect(
getFileDestinationPath({ destinationPath, platform, folder })
).toMatchSnapshot();
});
it("returns the destination path for the given file", () => {
expect(
getFileDestinationPath({ destinationPath, platform, folder, fileName })
).toMatchSnapshot();
});
});