summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/actions/tests/helpers/breakpoints.js
blob: 84eb83e23fe4271d36a39141ba92b8cf4d360ed3 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* 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 { createLocation } from "../../../utils/location";

export function mockPendingBreakpoint(overrides = {}) {
  const { sourceUrl, line, column, condition, disabled, hidden } = overrides;
  return {
    location: {
      sourceUrl: sourceUrl || "http://localhost:8000/examples/bar.js",
      line: line || 5,
      column: column || 1,
    },
    generatedLocation: {
      sourceUrl: sourceUrl || "http://localhost:8000/examples/bar.js",
      line: line || 5,
      column: column || 1,
    },
    astLocation: {
      name: undefined,
      offset: {
        line: line || 5,
      },
      index: 0,
    },
    options: {
      condition: condition || null,
      hidden: hidden || false,
    },
    disabled: disabled || false,
  };
}

export function generateBreakpoint(filename, line = 5, column = 0) {
  return {
    id: "breakpoint",
    originalText: "",
    text: "",
    location: createLocation({
      source: {
        url: `http://localhost:8000/examples/${filename}`,
        id: filename,
      },
      sourceId: filename,
      line,
      column,
    }),
    generatedLocation: createLocation({
      source: {
        url: `http://localhost:8000/examples/${filename}`,
        id: filename,
      },
      sourceId: filename,
      line,
      column,
    }),
    astLocation: undefined,
    options: {
      condition: "",
      hidden: false,
    },
    disabled: false,
  };
}