string-utils.js 984 B

12345678910111213141516171819202122232425262728
  1. (function (startsWith, endsWith) {
  2. 'use strict';
  3. QUnit.module("String Utils");
  4. QUnit.test("startsWith", function(assert) {
  5. assert.expect(4);
  6. assert.ok(startsWith("Boberson", "Bob"),
  7. 'found string at beginning of other string');
  8. assert.ok(!startsWith("Boberson", "bob"),
  9. 'function is case sensitive');
  10. assert.ok(!startsWith("Bob", "Boberson"),
  11. 'failed to find string at beginning of other string');
  12. assert.ok(!startsWith("", "Boberson"), 'tested empty string');
  13. });
  14. QUnit.test("endsWith", function(assert) {
  15. assert.expect(4);
  16. assert.ok(endsWith("Boberson", "son"),
  17. 'found string at the end of other string');
  18. assert.ok(!endsWith("Boberson", "Son"), 'function is case sensitive');
  19. assert.ok(!endsWith("Bob", "Boberson"),
  20. 'failed to find string at the end of other string');
  21. assert.ok(!endsWith("", "Boberson"), 'tested empty string');
  22. });
  23. }(Misago.prototype.startsWith, Misago.prototype.endsWith));