bod
Version:
Boilerplate CLI App
28 lines (27 loc) • 1.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const node_process_1 = tslib_1.__importDefault(require("node:process"));
const index_1 = require("../index");
describe('utils', () => {
it('should execute chalk correctly', () => {
expect((0, index_1.color)('raw text')).toStrictEqual('raw text');
});
it('should execute program correctly', () => {
const mockParse = jest.spyOn(index_1.program, 'parse').mockImplementation(jest.fn());
expect(node_process_1.default.env.__BOD__).toStrictEqual('__BOD__');
mockParse.mockRestore();
});
it('should return correct package manager', () => {
node_process_1.default.env.npm_config_user_agent = 'pnpm/8.15.0';
expect((0, index_1.findPackageManager)()).toStrictEqual('pnpm');
node_process_1.default.env.npm_config_user_agent = 'yarn/1.22.22';
expect((0, index_1.findPackageManager)()).toStrictEqual('yarn');
node_process_1.default.env.npm_config_user_agent = 'yarn/4.2.0';
expect((0, index_1.findPackageManager)()).toStrictEqual('yarn');
node_process_1.default.env.npm_config_user_agent = 'bun/0.1.0';
expect((0, index_1.findPackageManager)()).toStrictEqual('bun');
node_process_1.default.env.npm_config_user_agent = 'npm/10.0.0';
expect((0, index_1.findPackageManager)()).toStrictEqual('npm');
});
});