clean.js 707 B

1234567891011121314151617181920212223242526272829
  1. var tap = require('tap');
  2. var test = tap.test;
  3. var semver = require('../semver.js');
  4. var clean = semver.clean;
  5. test('\nclean tests', function(t) {
  6. // [range, version]
  7. // Version should be detectable despite extra characters
  8. [
  9. ['1.2.3', '1.2.3'],
  10. [' 1.2.3 ', '1.2.3'],
  11. [' 1.2.3-4 ', '1.2.3-4'],
  12. [' 1.2.3-pre ', '1.2.3-pre'],
  13. [' =v1.2.3 ', '1.2.3'],
  14. ['v1.2.3', '1.2.3'],
  15. [' v1.2.3 ', '1.2.3'],
  16. ['\t1.2.3', '1.2.3'],
  17. ['>1.2.3', null],
  18. ['~1.2.3', null],
  19. ['<=1.2.3', null],
  20. ['1.2.x', null]
  21. ].forEach(function(tuple) {
  22. var range = tuple[0];
  23. var version = tuple[1];
  24. var msg = 'clean(' + range + ') = ' + version;
  25. t.equal(clean(range), version, msg);
  26. });
  27. t.end();
  28. });