summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/utils/breakpoint/tests/index.spec.js
blob: fcfd155cff9bfc952a5d5df775d76577c113a7d3 (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
/* 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 { sortSelectedBreakpoints } from "../index";

import { makeMockBreakpoint, makeMockSource } from "../../test-mockup";

describe("breakpoint sorting", () => {
  it("sortSelectedBreakpoints should sort by line number and column", () => {
    const sorted = sortSelectedBreakpoints(
      [
        makeMockBreakpoint(undefined, 100, 2),
        makeMockBreakpoint(undefined, 9, 2),
        makeMockBreakpoint(undefined, 2),
        makeMockBreakpoint(undefined, 2, 7),
      ],
      makeMockSource()
    );

    expect(sorted[0].location.line).toBe(2);
    expect(sorted[0].location.column).toBe(undefined);
    expect(sorted[1].location.line).toBe(2);
    expect(sorted[1].location.column).toBe(7);
    expect(sorted[2].location.line).toBe(9);
    expect(sorted[3].location.line).toBe(100);
  });
});