callback.js 651 B

123456789101112131415161718192021222324252627282930313233
  1. var nomnom = require("../nomnom");
  2. exports.testVersion = function(test) {
  3. test.expect(1);
  4. nomnom().options({
  5. date: {
  6. callback: function(date) {
  7. test.equal(date, "2010-02-03", "date should match value")
  8. }
  9. }
  10. }).parse(["--date=2010-02-03"]);
  11. test.done();
  12. }
  13. exports.testReturnString = function(test) {
  14. test.expect(1);
  15. nomnom().options({
  16. version: {
  17. flag: true,
  18. callback: function() {
  19. return "v0.3";
  20. }
  21. }
  22. })
  23. .printer(function(string) {
  24. test.equal(0, string.indexOf("v0.3"))
  25. test.done();
  26. })
  27. .parse(["--version"]);
  28. }