diff --git a/test/highlighter/index.html b/test/highlighter/index.html
index 6f07cf80..f9f242bc 100644
--- a/test/highlighter/index.html
+++ b/test/highlighter/index.html
@@ -1,38 +1,19 @@
-
-
-
-
- Rangy - Highlighter Tests
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ QUnit Example
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/highlighter/index.test.ts b/test/highlighter/index.test.ts
index d95162df..45a067b0 100644
--- a/test/highlighter/index.test.ts
+++ b/test/highlighter/index.test.ts
@@ -1,15 +1,17 @@
-xn.test.suite("Highlighter module tests", function(s) {
- s.tearDown = function() {
- document.getElementById("test").innerHTML = "";
- };
+import * as rangy from "rangy2";
+import "rangy-classapplier";
+import "rangy-highlighter";
+import {createRangeInHtml} from "../testutils"
- s.test("highlightSelection test", function(t) {
+QUnit.module("Highlighter module tests");
+
+ QUnit.test("highlightSelection test", function(t) {
var applier = rangy.createClassApplier("c1");
var highlighter = rangy.createHighlighter();
highlighter.addClassApplier(applier);
var testEl = document.getElementById("test");
- var range = rangyTestUtils.createRangeInHtml(testEl, 'one [two] three four');
+ var range = createRangeInHtml(testEl, 'one [two] three four');
range.select();
var highlights = highlighter.highlightSelection("c1");
@@ -22,12 +24,10 @@ xn.test.suite("Highlighter module tests", function(s) {
});
- s.test("Options test (issue 249)", function(t) {
+ QUnit.test("Options test (issue 249)", function(t) {
var applier = rangy.createClassApplier("c1");
var highlighter = rangy.createHighlighter();
highlighter.addClassApplier(applier);
highlighter.highlightSelection("c1", { selection: rangy.getSelection() });
});
-
-}, false);
diff --git a/test/testutils.ts b/test/testutils.ts
index 0432c4f2..12c73d23 100644
--- a/test/testutils.ts
+++ b/test/testutils.ts
@@ -1,5 +1,7 @@
-var rangyTestUtils = (function() {
- function createNodeTree(levels, copiesPerLevel) {
+import * as rangy from "rangy2";
+import "core-js/es/map";
+
+ export function createNodeTree(levels, copiesPerLevel) {
function createTestNodes(parentNode, limit, copies) {
if (limit > 0) {
var n = parentNode.appendChild(document.createElement("div"));
@@ -19,9 +21,9 @@ var rangyTestUtils = (function() {
}
var nextIterationId = 1;
- var nodeIterationIds = new Hashtable();
+ var nodeIterationIds = new Map();
- function iterateNodes(node, func, includeSelf, iterationId) {
+ export function iterateNodes(node, func, includeSelf, iterationId?) {
if (!iterationId) {
iterationId = nextIterationId++;
}
@@ -31,27 +33,29 @@ var rangyTestUtils = (function() {
if (includeSelf) {
func(node);
}
- nodeIterationIds.put(node, iterationId);
+ nodeIterationIds.set(node, iterationId);
for (var child = node.firstChild, nextChild; !!child; child = nextChild) {
nextChild = child.nextSibling;
iterateNodes(child, func, true, iterationId);
}
}
- function RangeInfo() {}
-
- RangeInfo.prototype = {
- setStart: function(node, offset) {
+ export class RangeInfo {
+ sc: Node;
+ ec: Node;
+ so: number;
+ eo: number;
+ setStart(node, offset) {
this.sc = node;
this.so = offset;
- },
- setEnd: function(node, offset) {
+ }
+ setEnd(node, offset) {
this.ec = node;
this.eo = offset;
}
- };
+ }
- function createRangeInHtml(containerEl, html) {
+ export function createRangeInHtml(containerEl, html) {
containerEl.innerHTML = html;
var range = rangy.createRange(), foundStart = false;
var rangeInfo = new RangeInfo();
@@ -103,7 +107,7 @@ var rangyTestUtils = (function() {
return range;
}
- function getSortedClassName(el) {
+ export function getSortedClassName(el) {
return el.className.split(/\s+/).sort().join(" ");
}
@@ -112,7 +116,7 @@ var rangyTestUtils = (function() {
return r2.compareBoundaryPoints(r1.START_TO_START, r1);
}
- function htmlAndRangeToString(containerEl, range) {
+ export function htmlAndRangeToString(containerEl, range) {
function isElementRangeBoundary(el, offset, range, isStart) {
var prefix = isStart ? "start" : "end";
return (el == range[prefix + "Container"] && offset == range[prefix + "Offset"]);
@@ -173,15 +177,3 @@ var rangyTestUtils = (function() {
return getHtml(containerEl, false);
}
-
-
- return {
- createNodeTree: createNodeTree,
- RangeInfo: RangeInfo,
- iterateNodes: iterateNodes,
- createRangeInHtml: createRangeInHtml,
- getSortedClassName: getSortedClassName,
- htmlAndRangeToString: htmlAndRangeToString
- }
-
-})();