summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/utils/tests/ast.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/debugger/src/utils/tests/ast.spec.js')
-rw-r--r--devtools/client/debugger/src/utils/tests/ast.spec.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/devtools/client/debugger/src/utils/tests/ast.spec.js b/devtools/client/debugger/src/utils/tests/ast.spec.js
new file mode 100644
index 0000000000..0f00ae4fda
--- /dev/null
+++ b/devtools/client/debugger/src/utils/tests/ast.spec.js
@@ -0,0 +1,36 @@
+/* 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/>. */
+
+// @flow
+
+import { findBestMatchExpression } from "../ast";
+
+import { getSymbols } from "../../workers/parser/getSymbols";
+import { populateSource } from "../../workers/parser/tests/helpers";
+
+describe("find the best expression for the token", () => {
+ const source = populateSource("computed-props");
+ const symbols = getSymbols(source.id);
+
+ it("should find the identifier", () => {
+ const expression = findBestMatchExpression(symbols, {
+ line: 1,
+ column: 13,
+ });
+ expect(expression).toMatchSnapshot();
+ });
+
+ it("should find the expression for the property", () => {
+ const expression = findBestMatchExpression(symbols, {
+ line: 6,
+ column: 16,
+ });
+ expect(expression).toMatchSnapshot();
+ });
+
+ it("should find the identifier for computed member expressions", () => {
+ const expression = findBestMatchExpression(symbols, { line: 5, column: 6 });
+ expect(expression).toMatchSnapshot();
+ });
+});