@sentry/wizard
Version:
Sentry wizard helping you to configure your project
80 lines • 4.14 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
/// <reference types="jest" />
var fs = __importStar(require("fs"));
var path = __importStar(require("path"));
var MergeConfig_1 = require("../MergeConfig");
var configPath = path.join(__dirname, '..', 'test-fixtures/next.config.js');
var templatePath = path.join(__dirname, '..', '..', '..', 'scripts/NextJs/configs/next.config.template.js');
function configFileNames(num) {
var sourcePath = path.join(__dirname, '..', "test-fixtures/next.config.".concat(num, ".js"));
var mergedPath = path.join(__dirname, '..', "test-fixtures/next.config.".concat(num, "-merged.js"));
return { sourcePath: sourcePath, mergedPath: mergedPath };
}
describe('Merging next.config.js', function () {
afterEach(function () {
fs.unlinkSync(configPath);
});
test('merge basic next.config.js return true', function () {
var sourcePath = configFileNames(1).sourcePath;
fs.copyFileSync(sourcePath, configPath);
expect((0, MergeConfig_1.mergeConfigFile)(configPath, templatePath)).toBe(true);
});
test('merge basic next.config.js', function () {
var _a = configFileNames(1), sourcePath = _a.sourcePath, mergedPath = _a.mergedPath;
fs.copyFileSync(sourcePath, configPath);
(0, MergeConfig_1.mergeConfigFile)(configPath, templatePath);
expect(fs.readFileSync(configPath, 'utf8')).toEqual(fs.readFileSync(mergedPath, 'utf8'));
});
test('merge invalid javascript config return false', function () {
var sourcePath = configFileNames(2).sourcePath;
fs.copyFileSync(sourcePath, configPath);
expect((0, MergeConfig_1.mergeConfigFile)(configPath, templatePath)).toBe(false);
});
test('merge more complicated next.config.js return true', function () {
var sourcePath = configFileNames(3).sourcePath;
fs.copyFileSync(sourcePath, configPath);
expect((0, MergeConfig_1.mergeConfigFile)(configPath, templatePath)).toBe(true);
});
test('merge more complicated next.config.js', function () {
var _a = configFileNames(3), sourcePath = _a.sourcePath, mergedPath = _a.mergedPath;
fs.copyFileSync(sourcePath, configPath);
(0, MergeConfig_1.mergeConfigFile)(configPath, templatePath);
expect(fs.readFileSync(configPath, 'utf8')).toEqual(fs.readFileSync(mergedPath, 'utf8'));
});
test('merge next.config.js with function return true', function () {
var sourcePath = configFileNames(4).sourcePath;
fs.copyFileSync(sourcePath, configPath);
expect((0, MergeConfig_1.mergeConfigFile)(configPath, templatePath)).toBe(true);
});
test('merge next.config.js with function', function () {
var _a = configFileNames(4), sourcePath = _a.sourcePath, mergedPath = _a.mergedPath;
fs.copyFileSync(sourcePath, configPath);
(0, MergeConfig_1.mergeConfigFile)(configPath, templatePath);
expect(fs.readFileSync(configPath, 'utf8')).toEqual(fs.readFileSync(mergedPath, 'utf8'));
});
});
//# sourceMappingURL=MergeConfig.js.map