UNPKG

mediacentral-publish

Version:

A publish tool for publishing cloud-ux projects

72 lines (56 loc) 3.27 kB
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } const constants = require('../tests/constants'); const helper = require('./helper'); const fs = require('fs'); const child_process = require('child_process'); describe('helper', () => { beforeEach(_asyncToGenerator(function* () {})); afterEach(_asyncToGenerator(function* () {})); it('optionsValidation', _asyncToGenerator(function* () { const result = yield helper.optionsValidation(constants.buildAppObject); expect(result).toBeUndefined(); })); it('createWorkingDir', _asyncToGenerator(function* () { const path = yield helper.createWorkingDir(constants.project_path); expect(fs.existsSync(path)).toBeTruthy(); yield fs.rmdirSync(path); })); it('doSign', _asyncToGenerator(function* () { const result = yield helper.doSign(constants.keyWithPasswordPath, constants.manifetFilePath, constants.fs_file_path, constants.keyPassword, constants.developerID); expect(result.output.length > 0).toBeTruthy(); })); it('getFeaturePack', _asyncToGenerator(function* () { if (fs.existsSync(constants.feature_pack_path)) { yield fs.unlinkSync(constants.feature_pack_path); } const result = yield helper.getFeaturePack(constants.createdMetadataPath, constants.createdHelmPath, constants.createdImagePath, constants.project_version, constants.feature_pack_dir); expect(result.featurePackFile).toEqual(constants.feature_pack_path); if (fs.existsSync(constants.feature_pack_path)) { yield fs.unlinkSync(constants.feature_pack_path); } })); it('build', _asyncToGenerator(function* () { if (!fs.existsSync(constants.build_app_path)) { fs.mkdirSync(constants.build_app_path); } constants.copyFolderRecursiveSync(constants.test_app_path, constants.build_app_path); yield child_process.execSync(`npm install --prefix ${constants.copied_app_path}`); const path = yield helper.createWorkingDir(constants.copied_app_path); try { const result = yield helper.build(constants.build_config_object(path), constants.doStep); expect(fs.existsSync(result.featurePack.featurePackFile)).toBeTruthy(); } finally { constants.deleteFolderRecursive(constants.build_app_path); } }), 240000); it('doUpload', _asyncToGenerator(function* () { if (!fs.existsSync(constants.build_app_path)) { fs.mkdirSync(constants.build_app_path); } constants.copyFolderRecursiveSync(constants.test_app_path, constants.build_app_path); yield helper.doUpload(constants.manifetFilePath, constants.createdMetadataPath, constants.appID).catch(function (e) { expect(e.message.includes('Application Id is invalid')).toBeTruthy(); }); constants.deleteFolderRecursive(constants.copied_app_path); }), 120000); });