mediacentral-publish
Version:
A publish tool for publishing cloud-ux projects
33 lines (27 loc) • 1.85 kB
JavaScript
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 createMetadata = require('./createMetadata');
const fs = require('./fs');
const path = require('path');
describe('createMetadata File', () => {
beforeEach(_asyncToGenerator(function* () {
yield fs.removePromise(path.join(constants.metadata_path, 'metadata.json'));
}));
afterEach(_asyncToGenerator(function* () {
yield fs.removePromise(path.join(constants.metadata_path, 'metadata.json'));
}));
it('return output and filePath', _asyncToGenerator(function* () {
const result = yield createMetadata(constants.metadata_path, constants.project_name, constants.project_version, constants.project_organization);
const filePath = path.join(constants.metadata_path, 'metadata.json');
expect(result).toEqual({
output: `A metadata file created in ${filePath}.`,
file: filePath
});
}));
it('correct metadata file', _asyncToGenerator(function* () {
yield createMetadata(constants.metadata_path, constants.project_name, constants.project_version, constants.project_organization);
const filePath = path.join(constants.metadata_path, 'metadata.json');
const metadata = JSON.parse((yield fs.readFilePromise(filePath)));
expect(metadata).toEqual(constants.correct_metadata);
}));
});