react-native-integrate
Version:
Automate integration of additional code into React Native projects
36 lines (35 loc) • 2.06 kB
JavaScript
;
/* eslint-disable @typescript-eslint/no-unsafe-call */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const { mockFs } = require('../mocks/mockAll');
const path_1 = __importDefault(require("path"));
const picocolors_1 = __importDefault(require("picocolors"));
const constants_1 = require("../../constants");
const getInfo_1 = require("../../getInfo");
const getPackageConfig_1 = require("../../utils/getPackageConfig");
const mockAll_1 = require("../mocks/mockAll");
const mockIntegrateYml_1 = require("../mocks/mockIntegrateYml");
describe('getInfo', () => {
it('should get info of package', async () => {
mockAll_1.mockPrompter.log.success.mockReset();
await (0, getInfo_1.getInfo)('mock-package');
expect(mockAll_1.mockPrompter.log.success).toHaveBeenCalledWith(expect.stringContaining('ready and available for integration'));
});
it('should get info of non existing package', async () => {
mockAll_1.mockPrompter.log.warning.mockReset();
await (0, getInfo_1.getInfo)('mock-package-fail');
expect(mockAll_1.mockPrompter.log.warning).toHaveBeenCalledWith(expect.stringContaining('not available for integration'));
});
it('should get info of local configured package', async () => {
const packageName = '@react-native-firebase/app';
const localPackagePath = (0, getPackageConfig_1.getPackagePath)(packageName);
const localConfigPath = path_1.default.join(localPackagePath, constants_1.Constants.CONFIG_FILE_NAME);
mockFs.writeFileSync(localConfigPath, mockIntegrateYml_1.mockIntegrateYml);
mockAll_1.mockPrompter.log.step.mockReset();
await (0, getInfo_1.getInfo)(packageName);
expect(mockAll_1.mockPrompter.log.step).toHaveBeenCalledWith(expect.stringContaining(`local configuration: ${picocolors_1.default.bold(picocolors_1.default.green('exists'))}`));
});
});