summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/utils/tests/result-list.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/debugger/src/utils/tests/result-list.spec.js')
-rw-r--r--devtools/client/debugger/src/utils/tests/result-list.spec.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/devtools/client/debugger/src/utils/tests/result-list.spec.js b/devtools/client/debugger/src/utils/tests/result-list.spec.js
new file mode 100644
index 0000000000..dcbaf421c5
--- /dev/null
+++ b/devtools/client/debugger/src/utils/tests/result-list.spec.js
@@ -0,0 +1,32 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
+
+import { scrollList } from "../result-list.js";
+
+describe("scrollList", () => {
+ beforeEach(() => {
+ jest.useFakeTimers();
+ });
+
+ /* eslint-disable jest/expect-expect */
+ it("just returns if element not found", () => {
+ const li = document.createElement("li");
+ scrollList([li], 1);
+ });
+ /* eslint-enable jest/expect-expect */
+
+ it("calls scrollIntoView", () => {
+ const ul = document.createElement("ul");
+ const li = document.createElement("li");
+
+ li.scrollIntoView = jest.fn();
+ ul.appendChild(li);
+
+ scrollList([li], 0);
+
+ jest.runAllTimers();
+
+ expect(li.scrollIntoView).toHaveBeenCalled();
+ });
+});