Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

[Breakpoints] setting a condition should enable a breakpoint #3765

Merged
merged 3 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/actions/breakpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ export function setBreakpointCondition(
throw new Error("breakpoint must be saved");
}

if (bp.disabled) {
await dispatch(enableBreakpoint(location));
bp.disabled = !bp.disabled;
}

await client.setBreakpointCondition(
bp.id,
location,
Expand Down
26 changes: 26 additions & 0 deletions src/actions/tests/breakpoints.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,32 @@ describe("breakpoints", () => {
);
});

it("should set the condition and enable a breakpoint", async () => {
const { dispatch, getState } = createStore(simpleMockThreadClient);

const loc = {
sourceId: "a",
line: 5,
sourceUrl: "http://localhost:8000/examples/a"
};

await dispatch(actions.newSource(makeSource("a")));
await dispatch(actions.addBreakpoint(loc));
await dispatch(actions.disableBreakpoint(loc));

expect(selectors.getBreakpoint(getState(), loc).condition).toBe(null);

await dispatch(
actions.setBreakpointCondition(loc, {
condition: "const foo = 0",
getTextForLine: () => {}
})
);
const breakpoint = selectors.getBreakpoint(getState(), loc);
expect(breakpoint.disabled).toBe(false);
expect(breakpoint.condition).toBe("const foo = 0");
});

it("should remap breakpoints on pretty print", async () => {
const { dispatch, getState } = createStore(simpleMockThreadClient);

Expand Down