h.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict';
  2. const chai = require('chai');
  3. const mixitup = require('../../dist/mixitup.js');
  4. const h = mixitup.h;
  5. describe('h#compareVersions()', () => {
  6. it('should return true if versions are matching', () => {
  7. let result = h.compareVersions('1.0.0', '1.0.0');
  8. chai.assert.isOk(result);
  9. });
  10. it('should return false if specimen version is less than control', () => {
  11. let result = h.compareVersions('1.0.0', '0.1.2');
  12. chai.assert.isNotOk(result);
  13. });
  14. it('should return true if specimen version is greater than control', () => {
  15. let result = h.compareVersions('1.0.0', '1.1.2');
  16. chai.assert.isOk(result);
  17. });
  18. it('should return true if specimen version is greater than control, with double figures', () => {
  19. let result = h.compareVersions('3.0.0', '10.1.2');
  20. chai.assert.isOk(result);
  21. });
  22. it('should handle semver carat notation', () => {
  23. let result = h.compareVersions('^3.0.0', '2.0.0');
  24. chai.assert.isNotOk(result);
  25. });
  26. it('should handle semver label notation', () => {
  27. let result = h.compareVersions('^3.0.0', '3.0.0-beta');
  28. chai.assert.isOk(result);
  29. });
  30. });