1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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();
});
});
|