index.js 1.7 KB

123456789101112131415161718192021222324252627
  1. "use strict";
  2. // Dependencies
  3. var isSsh = require("../lib"),
  4. tester = require("tester");
  5. // Prepare the input data
  6. var input = [
  7. // Secure Shell Transport Protocol (SSH)
  8. ["ssh://user@host.xz:port/path/to/repo.git/", true], ["ssh://user@host.xz/path/to/repo.git/", true], ["ssh://host.xz:port/path/to/repo.git/", true], ["ssh://host.xz/path/to/repo.git/", true], ["ssh://user@host.xz/path/to/repo.git/", true], ["ssh://host.xz/path/to/repo.git/", true], ["ssh://user@host.xz/~user/path/to/repo.git/", true], ["ssh://host.xz/~user/path/to/repo.git/", true], ["ssh://user@host.xz/~/path/to/repo.git", true], ["ssh://host.xz/~/path/to/repo.git", true], ["user@host.xz:/path/to/repo.git/", true], ["user@host.xz:~user/path/to/repo.git/", true], ["user@host.xz:path/to/repo.git", true], ["host.xz:/path/to/repo.git/", true], ["host.xz:path/to/repo.git", true], ["host.xz:~user/path/to/repo.git/", true], ["rsync://host.xz/path/to/repo.git/", true]
  9. // Git Transport Protocol
  10. , ["git://host.xz/path/to/repo.git/", false], ["git://host.xz/~user/path/to/repo.git/", false]
  11. // HTTP/S Transport Protocol
  12. , ["http://host.xz/path/to/repo.git/", false], ["https://host.xz/path/to/repo.git/", false], ["http://host.xz:8000/path/to/repo.git/", false], ["https://host.xz:8000/path/to/repo.git/", false]
  13. // Local (Filesystem) Transport Protocol
  14. , ["/path/to/repo.git/", false], ["path/to/repo.git/", false], ["~/path/to/repo.git", false], ["file:///path/to/repo.git/", false], ["file://~/path/to/repo.git/", false]];
  15. tester.describe("check urls", function (test) {
  16. // Run the tests
  17. input.forEach(function (c) {
  18. test.it(c[0] + " is supposed " + (!c[1] ? "not " : "") + "to be a ssh url", function () {
  19. test.expect(isSsh(c[0])).toBe(c[1]);
  20. });
  21. });
  22. });