Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
declare const generator: Generator;
declare function before(done: (...args: any[]) => void): void;
// helpers.setUpTestDirectory()
before(helpers.setUpTestDirectory('dir'));
// helpers.gruntfile()
before(done => helpers.gruntfile({foo: 'bar'}, done));
// 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',
it("creates expected files when processors are expected", function(done) {
var expected = [
"lib/processors",
"tests/lib/processors",
"lib/index.js",
"package.json",
"README.md"
];
helpers.mockPrompt(this.rule, {
userName: "Foo Bar",
pluginId: "eslint-plugin-foo-bar",
desc: "My foo",
hasRules: false,
hasProcessors: true
});
this.rule.options["skip-install"] = true;
this.rule.run(function() {
assert.file(expected);
done();
});
});
it('should use existing config if available', function(done) {
this.timeout(60000);
copySync(__dirname + '/fixtures/.yo-rc.json', __dirname + '/temp/.yo-rc.json');
var gen = helpers.createGenerator('angular-fullstack:app', [
'../../generators/app',
'../../generators/endpoint',
[
helpers.createDummyGenerator(),
'ng-component:app'
]
], [], {
skipInstall: true
});
helpers.mockPrompt(gen, {
skipConfig: true
});
gen.run(function () {
assert.file([
'client/app/main/main.less',
'server/auth/google/passport.js'
]);
done();
});
});
it('creates expected files', function (done) {
var expected = [
'index.js',
'test/index.js',
'.gitignore',
'.jshintrc',
'.travis.yml',
['package.json', /"name": "mymodule"/],
['Gruntfile.js', /!node_modules/],
'README.md',
'LICENSE'
];
helpers.mockPrompt(this.app, {
'moduleName': 'mymodule',
'moduleDesc': 'awesome module',
'keywords': 'something',
'useGrunt': true,
'testFramework': 'mocha',
'assertionLibrary': 'expect.js',
'githubName': 'octocat',
'author': 'Octo Cat '
});
this.app.run(function () {
expected.forEach(function (file) {
if (typeof file === 'string') {
assert.file(file);
} else if (Array.isArray(file)) {
assert.fileContent(file[0], file[1]);
beforeEach(function(done) {
helpers.mockPrompt(gen, {
script: 'js',
markup: 'html',
stylesheet: 'css',
router: 'ngroute',
mongoose: false,
auth: false,
oauth: [],
socketio: false
});
done();
});
/*
* Adapted from:
* http://stackoverflow.com/questions/27643601/testing-yeomans-composewith
* Adapted to use createGenerator and the .run() method on generator
* instances. The idea is that the dummyGenerator is being assigned
* the namespace "eslint:plugin" for this test, so when the main
* generator invokes "eslint:plugin", it will run our
* dummyGenerator's exec() function and thus call our spy.
*/
this.eslintGenerator = helpers.createGenerator("eslint", [
"../app",
[this.dummyGenerator, "eslint:plugin"]
]);
helpers.mockPrompt(this.eslintGenerator, {
outputType: "Plugin"
});
this.eslintGenerator.options["skip-install"] = true;
this.eslintGenerator.run(done);
});
beforeEach(function() {
helpers.mockPrompt(gen, defaultOptions);
});
beforeEach(function() {
helpers.mockPrompt(gen, defaultOptions);
});
co(function * dist() {
try {
yield rimraf(path.join(__dirname, `../dist`));
for (const options of combinations.full()) {
const combinationPath = path.join(__dirname, `../dist/${options.framework}-${options.modules}-${options.js}-${options.css}-${options.router}-${options.sample}`);
yield mkdirp(combinationPath);
const fountain = helpers.createGenerator('fountain-webapp:app', [generatorPath], null, {
'skipInstall': true,
'skip-welcome-message': true
});
fountain.env.cwd = combinationPath;
helpers.mockPrompt(fountain, options);
const run = Promise.promisify(fountain.run.bind(fountain));
output.mute();
yield run();
output.unmute();
yield zip.zipFolder(combinationPath, `${combinationPath}.zip`);
console.log('Generated', combinationPath);
}
} catch (error) {
console.log('Something went wrong', error);
}
});
auth: true,
oauth: ['googleAuth', 'twitterAuth'],
ws: true
};
var deps = [
'../app',
[
helpers.createDummyGenerator(),
'ng-component:app'
]
];
var gen = helpers.createGenerator('angular-fullstack:app', deps);
helpers.mockPrompt(gen, options);
gen.run({}, function () {
deferred.resolve();
});
return deferred.promise;
}
});