stringTest.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * Created by Tony on 2017/4/7.
  3. */
  4. var test = require('tape');
  5. var strUtil = require('../../public/stringUtil');
  6. //test('some string test cases', function (t) {
  7. // var reg = /^\s*$/;
  8. // var foo = " ";
  9. // t.equal(reg.test(foo), true);
  10. // foo = null;
  11. // t.equal(reg.test(foo), true);
  12. // foo = undefined;
  13. // t.equal(reg.test(foo), true);
  14. // foo = "";
  15. // t.equal(reg.test(foo), true);
  16. // foo = 0;
  17. // t.equal(reg.test(foo), true);
  18. // t.end();
  19. //});
  20. //
  21. //test('check if string type', function(t){
  22. // var foo = "";
  23. // t.equal(typeof foo, 'string');
  24. // foo = " ";
  25. // t.equal(typeof foo, 'string');
  26. // foo = 0;
  27. // t.equal(typeof foo, 'number');
  28. // foo = true;
  29. // t.equal(typeof foo, 'boolean');
  30. // foo = {};
  31. // t.equal(typeof foo, 'object');
  32. // foo = function(){};
  33. // t.equal(typeof foo, 'function');
  34. // foo = [];
  35. // t.equal(Array.isArray(foo), true);
  36. // t.end();
  37. //})
  38. // test('test number to Chinese', function(t){
  39. // //t.equal(strUtil.convertNumToChinese(1, true), '壹');
  40. // //t.equal(strUtil.convertNumToChinese(1, false), '一');
  41. // t.equal(strUtil.convertNumToChinese(11, false), '一十一');
  42. // t.equal(strUtil.convertNumToChinese(12, false), '一十二');
  43. // t.equal(strUtil.convertNumToChinese(21, false), '二十一');
  44. // //console.log(strUtil.convertNumToChinese(102, false));
  45. // t.equal(strUtil.convertNumToChinese(102, false), '一百零二');
  46. // t.end();
  47. // });
  48. // test('test 拼音', function(t){
  49. // t.equal(strUtil.getPinYinCamelChars("招标清单"), "ZBQD");
  50. // t.equal(strUtil.getPinYinCamelChars("1. 招标清单"), "1. ZBQD");
  51. // t.end();
  52. // })
  53. test('test typeof', function(t){
  54. t.equal(typeof(true), "boolean");
  55. t.equal((typeof("abc")).toUpperCase(), "STRING");
  56. t.equal(typeof(1), "number");
  57. t.end();
  58. })