http.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* eslint-env node */
  2. /* eslint global-require: 0, func-names: 0, no-shadow: 0 */
  3. "use strict";
  4. const t = require("tap");
  5. let H9Y = null;
  6. t.beforeEach(function setup(done) {
  7. H9Y = require("../hyphenopoly.module");
  8. done();
  9. });
  10. t.afterEach(function tearDown(done) {
  11. H9Y = null;
  12. delete require.cache[require.resolve("../hyphenopoly.module")];
  13. done();
  14. });
  15. t.test("run config with one language", async function (t) {
  16. const deHyphenator = await H9Y.config({
  17. "loader": "https",
  18. "paths": {
  19. "maindir": "https://unpkg.com/hyphenopoly@3.1.0/",
  20. "patterndir": "https://unpkg.com/hyphenopoly@3.1.0/patterns/"
  21. },
  22. "require": ["de"]
  23. });
  24. t.test("return a function", function (t) {
  25. t.equal(typeof deHyphenator, "function", typeof deHyphenator);
  26. t.end();
  27. });
  28. t.test("hyphenate one word", function (t) {
  29. t.equal(deHyphenator("Silbentrennung"), "Sil\u00ADben\u00ADtren\u00ADnung", deHyphenator("Silbentrennung"));
  30. t.end();
  31. });
  32. t.test("hyphenate two words", function (t) {
  33. t.equal(deHyphenator("Silbentrennung Algorithmus"), "Sil\u00ADben\u00ADtren\u00ADnung Al\u00ADgo\u00ADrith\u00ADmus", deHyphenator("Silbentrennung Algorithmus"));
  34. t.end();
  35. });
  36. t.end();
  37. });