Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('sets appropriate validate function', function () {
const myprompt = state.generator.processedPrompts[1];
assert.ok(myprompt.hasOwnProperty('validate'));
const validate = myprompt.validate;
let v = validate('');
// In IntelliJ, we get the ASCII back, in a terminal we don't. Just stripping it!
assert.equal(stripAnsi(v), 'The required myprompt value is missing or invalid');
v = validate('a value');
assert.equal(v, true);
});
it('sets appropriate filter function', function () {
const myprompt = state.generator.processedPrompts[1];
assert.ok(myprompt.hasOwnProperty('filter'));
const filter = myprompt.filter;
let v = filter('');
assert.equal(v, undefined);
v = filter(123);
assert.equal(v, '123');
});
it('set the CWD where `.yo-rc.json` is found', function() {
const projectDir = path.join(__dirname, 'fixtures/dummy-project');
const subdir = path.join(projectDir, 'subdir');
process.chdir(subdir);
this.env.cwd = process.cwd();
const dummy = new this.Dummy(['foo'], {
resolved: 'ember/all',
env: this.env
});
assert.equal(process.cwd(), projectDir);
assert.equal(dummy.destinationPath(), projectDir);
assert.equal(dummy.contextRoot, subdir);
});
it('handles option values', function () {
assert.equal(state.bail, false);
assert.equal(state.myargument, 'my-argument');
assert.equal(state.myprompt, 'option value');
});
return function() {
assert.equal(e, lifecycle.shift());
if (e === 'end') {
done();
}
};
}