Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// helpers.testDirectory()
helpers.testDirectory(path.join(__dirname, './temp'), () => {
fs.writeFileSync('testfile', 'Roses are red.');
});
// helpers.mockPrompt()
helpers.mockPrompt(generator, {foo: 'bar'});
// helpers.restorePrompt()
helpers.restorePrompt(generator);
// helpers.mockLocalConfig()
helpers.mockLocalConfig(generator, {foo: 'bar'});
// helpers.createDummyGenerator()
const dummyGenerator = helpers.createDummyGenerator();
// helpers.createGenerator()
const angularGenerator = helpers.createGenerator('angular:app', [
'../../app',
'../../common',
'../../controller',
'../../main',
[helpers.createDummyGenerator(), 'testacular:app']
]);
// helpers.registerDependencies()
helpers.registerDependencies(env, ['dependency']);
// helpers.run()
helpers.run(path.join(__dirname, '../app'))
.withOptions({foo: 'bar'})
packageFolder: 'com/mycompany/myapp',
authenticationType: 'jwt',
cacheProvider: 'ehcache',
websocket: false,
databaseType: 'sql',
devDatabaseType: 'h2Disk',
prodDatabaseType: 'mysql',
searchEngine: false,
buildTool: 'maven',
enableTranslation: true,
nativeLanguage: 'en',
languages: ['en', 'fr'],
testFrameworks: ['gatling', 'protractor'],
jhiPrefix: 'jhi'
};
const loadedConfig = utils.getAllJhipsterConfig(helpers.createDummyGenerator(), true, configRootDir);
assert.objectContent(loadedConfig, expectedConfig);
});
it('correctly handles deprecated blueprint information', () => {
before(function () {
mockery.enable({
warnOnUnregistered: false
})
mockery.registerMock('npm-name', function (name, cb) {
cb(null, true)
})
mockery.registerMock('github-username', function (name, cb) {
cb(null, 'unicornUser')
})
mockery.registerMock(
require.resolve('generator-license/app'),
helpers.createDummyGenerator()
)
mockery.registerMock('deps-object', function (deps) {
var obj = deps.reduce(function (o, v) {
var tok = v.split('@')
if (tok.length === 1) tok.push('*')
o[tok[0]] = tok[1]
return o
}, {})
return Promise.resolve(obj)
})
})
warnOnUnregistered: false
});
mockery.registerMock('npm-name', () => {
return new Promise(resolve => {
resolve(true);
});
});
mockery.registerMock('github-username', () => {
return Promise.resolve('unicornUser');
});
mockery.registerMock(
require.resolve('generator-license'),
helpers.createDummyGenerator()
);
});
mockery.enable({
warnOnReplace: false,
warnOnUnregistered: false
});
mockery.registerMock('npm-name', function () {
return Promise.resolve(true);
});
mockery.registerMock('github-username', function (name, cb) {
cb(null, 'unicornUser');
});
mockery.registerMock(
require.resolve('generator-license/app'),
helpers.createDummyGenerator()
);
});
beforeTestCb,
assertionCb
).withGenerators([
[helpers.createDummyGenerator(), 'confit:buildBrowser'],
[helpers.createDummyGenerator(), 'confit:buildAssets'],
[helpers.createDummyGenerator(), 'confit:buildCSS'],
[helpers.createDummyGenerator(), 'confit:buildHTML'],
[helpers.createDummyGenerator(), 'confit:buildJS'],
[helpers.createDummyGenerator(), 'confit:documentation'],
[helpers.createDummyGenerator(), 'confit:entryPoint'],
[helpers.createDummyGenerator(), 'confit:paths'],
[helpers.createDummyGenerator(), 'confit:release'],
[helpers.createDummyGenerator(), 'confit:sampleApp'],
[helpers.createDummyGenerator(), 'confit:serverDev'],
[helpers.createDummyGenerator(), 'confit:serverProd'],
[helpers.createDummyGenerator(), 'confit:testSystem'],
[helpers.createDummyGenerator(), 'confit:testVisualRegression'],
[helpers.createDummyGenerator(), 'confit:testUnit'],
[helpers.createDummyGenerator(), 'confit:verify'],
[helpers.createDummyGenerator(), 'confit:zzfinish'],
]);
}
function runWithPrompts(prompts, callback) {
helpers.run(path.join(__dirname, '../generators/app'))
.inDir(path.join(__dirname, 'temp'))
.withGenerators([
[helpers.createDummyGenerator(), 'mocha:app'],
[helpers.createDummyGenerator(), 'jasmine:app']
])
.withPrompts(prompts)
.on('end', callback);
}