string-count.js 619 B

123456789101112131415161718
  1. import assert from 'assert';
  2. import stringCount from 'misago/utils/string-count';
  3. describe('String Count', function() {
  4. it("counts number of occurences of needle in haystack", function() {
  5. assert.equal(stringCount("lorem ipsum", "dolor"), 0,
  6. "nonexistant needle wasn't found in haystack");
  7. assert.equal(stringCount("lorem ipsum", "ore"), 1,
  8. "needle was found in haystack once");
  9. assert.equal(stringCount("lOrEm ipsum", "oRe"), 1,
  10. "search is case-insensitive");
  11. assert.equal(stringCount("lorem ipsum dolorem met.", "ore"), 2,
  12. "needle was found in haystack twice");
  13. });
  14. });