_tests.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. var assert = require("chai").assert;
  3. module.exports = function (includes) {
  4. it("Should return true when context contains search string", function () {
  5. assert.equal(includes.call("razdwatrzy", "dwa"), true);
  6. });
  7. it("Should return true when context starts with search string", function () {
  8. assert.equal(includes.call("razdwa", "raz"), true);
  9. });
  10. it("Should return true when context ends with search string", function () {
  11. assert.equal(includes.call("razdwa", "dwa"), true);
  12. });
  13. it("Should return false when string doesn't contain search string", function () {
  14. assert.equal(includes.call("razdwa", "trzy"), false);
  15. });
  16. it("Should return false when context is empty and search string is not", function () {
  17. assert.equal(includes.call("", "a"), false);
  18. });
  19. it("Should return false when search string is longer than context", function () {
  20. assert.equal(includes.call("raz", "razdwa"), false);
  21. });
  22. it("Should return true when search string is same as context ", function () {
  23. assert.equal(includes.call("raz", "raz"), true);
  24. });
  25. it("Should return true when context starts with search string", function () {
  26. assert.equal(includes.call("razdwa", "raz"), true);
  27. });
  28. it("Should return true when search string is empty", function () {
  29. assert.equal(includes.call("raz", ""), true);
  30. });
  31. it("Should return true when both context and search string are empty", function () {
  32. assert.equal(includes.call("", ""), true);
  33. });
  34. it("Should support position argument", function () {
  35. assert.equal(includes.call("razdwa", "raz", 1), false);
  36. assert.equal(includes.call("razdwa", "dwa", 1), true);
  37. });
  38. };