util.test.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { limit, trimAfterFirstMatch, startsWith, endsWith } from './util.js';
  2. describe('findNumbers/util', function () {
  3. it('should generate regexp limit', function () {
  4. var thrower = function thrower() {
  5. return limit(1, 0);
  6. };
  7. thrower.should["throw"]();
  8. thrower = function thrower() {
  9. return limit(-1, 1);
  10. };
  11. thrower.should["throw"]();
  12. thrower = function thrower() {
  13. return limit(0, 0);
  14. };
  15. thrower.should["throw"]();
  16. });
  17. it('should trimAfterFirstMatch', function () {
  18. trimAfterFirstMatch(/\d/, 'abc123').should.equal('abc');
  19. trimAfterFirstMatch(/\d/, 'abc').should.equal('abc');
  20. });
  21. it('should determine if a string starts with a substring', function () {
  22. startsWith('𐍈123', '𐍈').should.equal(true);
  23. startsWith('1𐍈', '𐍈').should.equal(false);
  24. });
  25. it('should determine if a string ends with a substring', function () {
  26. endsWith('123𐍈', '𐍈').should.equal(true);
  27. endsWith('𐍈1', '𐍈').should.equal(false);
  28. });
  29. });
  30. //# sourceMappingURL=util.test.js.map