summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/workers/parser/tests/getSymbols.spec.js
blob: 9e8ea1dc1dec0fbfc17d75d8f5f05818533c89d3 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* eslint max-nested-callbacks: ["error", 4]*/
/* 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 { formatSymbols } from "../utils/formatSymbols";
import { populateSource, populateOriginalSource } from "./helpers";
import cases from "jest-in-case";

cases(
  "Parser.getSymbols",
  ({ name, file, original, type }) => {
    const source = original
      ? populateOriginalSource(file, type)
      : populateSource(file, type);

    expect(formatSymbols(source.id)).toMatchSnapshot();
  },
  [
    { name: "es6", file: "es6", original: true },
    { name: "func", file: "func", original: true },
    { name: "function names", file: "functionNames", original: true },
    { name: "math", file: "math" },
    { name: "proto", file: "proto" },
    { name: "class", file: "class", original: true },
    { name: "var", file: "var" },
    { name: "expression", file: "expression" },
    { name: "allSymbols", file: "allSymbols" },
    { name: "call sites", file: "call-sites" },
    { name: "call expression", file: "callExpressions" },
    { name: "object expressions", file: "object-expressions" },
    { name: "optional chaining", file: "optional-chaining" },
    {
      name: "finds symbols in an html file",
      file: "parseScriptTags",
      type: "html",
    },
    { name: "component", file: "component", original: true },
    {
      name: "react component",
      file: "frameworks/reactComponent",
      original: true,
    },
    { name: "flow", file: "flow", original: true },
    { name: "jsx", file: "jsx", original: true },
    { name: "destruct", file: "destructuring" },
  ]
);