Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/node_modules/nomnom/test/ |
Upload File : |
var nomnom = require("../nomnom"); function strip(str) { return str.replace(/\s+/g, ''); } exports.testCallback = function(test) { test.expect(1); var parser = nomnom(); parser.command('run').callback(function(options) { test.equal(options.v, 3); }); parser.command('other').callback(function() { test.ok(false, "callback for other command shouldn't be called"); }); parser.parse(["run","-v", "3"]); test.done(); } exports.testMissingCommand = function(test) { test.expect(1); var parser = nomnom().scriptName("test"); parser.command('run'); parser.printer(function(string) { test.equal(string, "test: no such command 'other'"); test.done(); }); parser.parse(["other"]); } exports.testNoCommand = function(test) { test.expect(2); var parser = nomnom(); parser.nocommand() .options({ version: { flag: true } }) .callback(function(options) { test.strictEqual(options.version, true); }) .usage("fallback usage"); parser.command('run'); var options = parser.parse(["--version"]); test.strictEqual(options.version, true); test.done(); } function createParser() { var parser = nomnom().scriptName("test") .options({ debug: { flag: true } }); parser.command('run') .options({ file: { help: 'file to run' } }) .help("run all"); parser.command('test').usage("test usage"); parser.nocommand() .options({ verbose: { flag: true } }) .help("nocommand"); return parser; } exports.testUsage = function(test) { test.expect(4); var parser = createParser(); parser.printer(function(string) { test.equal(strip(string), "testusage"); }); parser.parse(["test", "-h"]); parser = createParser().nocolors(); parser.printer(function(string) { test.equal(strip(string), "Usage:testrun[options]Options:--debug--filefiletorunrunall"); }); parser.parse(["run", "-h"]); parser = createParser().nocolors(); parser.printer(function(string) { test.equal(strip(string), "Usage:test[command][options]commandoneof:run,testOptions:--debug--verbosenocommand"); }); parser.parse(["-h"]); parser = createParser().nocolors(); parser.nocommand() .usage("fallback"); parser.printer(function(string) { test.equal(strip(string), "fallback"); }); parser.parse(["-h"]); test.done(); }