@applicaster/zapplicaster-cli
Version:
CLI Tool for the zapp app and Quick Brick project
48 lines (38 loc) • 1.36 kB
JavaScript
const { isZappReactNativeRepo, getCLIProperties } = require("../index");
const logger = require("../../logger");
const path = require("path");
const logSpy = jest.spyOn(logger, "warn").mockImplementation(() => ({}));
const processSpy = jest.spyOn(process, "cwd");
// const resolveSpy = jest.spyOn(path, "resolve");
describe("isZappReactNativeRepo", () => {
afterEach(() => {
logSpy.mockClear();
});
it("returns true if the cli is running from the zapp-react-native-repo", () => {
expect(isZappReactNativeRepo()).toBe(true);
});
it("returns false otherwise", () => {
processSpy.mockImplementation(() =>
path.resolve(__dirname, "./fixtures/folderWithPackageJson")
);
expect(isZappReactNativeRepo()).toBe(false);
});
it("returns false if no package.json is found", () => {
processSpy.mockImplementation(() =>
path.resolve(__dirname, "./fixtures/folderWithoutPackageJson")
);
expect(isZappReactNativeRepo()).toBe(false);
expect(logSpy).toHaveBeenCalledWith("There is no package.json file here !");
});
});
describe("getCLIProperties", () => {
it("returns the cli package's name & version", () => {
const { name, version } = require(
path.resolve(__dirname, "../../../package.json")
);
expect(getCLIProperties()).toEqual({
name,
version,
});
});
});