From cdd47c1bcd629d61dc7d55ad6c1368943aa91f6d Mon Sep 17 00:00:00 2001 From: Sagorika Das Date: Wed, 23 Aug 2017 01:40:32 +0530 Subject: [PATCH 1/3] The disabled breakpoint is replaced with a conditional breakpoint. --- src/actions/breakpoints.js | 5 +++++ src/actions/tests/breakpoints.spec.js | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/actions/breakpoints.js b/src/actions/breakpoints.js index efa4638a46..4c1c1961f6 100644 --- a/src/actions/breakpoints.js +++ b/src/actions/breakpoints.js @@ -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, diff --git a/src/actions/tests/breakpoints.spec.js b/src/actions/tests/breakpoints.spec.js index c963e45e47..62ecaa7cf8 100644 --- a/src/actions/tests/breakpoints.spec.js +++ b/src/actions/tests/breakpoints.spec.js @@ -272,6 +272,33 @@ 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); From 5705ab1a5819ebb0066acd63df513df8a5e95a31 Mon Sep 17 00:00:00 2001 From: Sagorika Das Date: Wed, 23 Aug 2017 02:16:04 +0530 Subject: [PATCH 2/3] Removed empty line --- src/actions/tests/breakpoints.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/actions/tests/breakpoints.spec.js b/src/actions/tests/breakpoints.spec.js index 62ecaa7cf8..db5f8c4a16 100644 --- a/src/actions/tests/breakpoints.spec.js +++ b/src/actions/tests/breakpoints.spec.js @@ -272,7 +272,6 @@ describe("breakpoints", () => { ); }); - it("should set the condition and enable a breakpoint", async () => { const { dispatch, getState } = createStore(simpleMockThreadClient); From 84920b631e5094369a90f03b930ff036345bf6f9 Mon Sep 17 00:00:00 2001 From: codehag Date: Wed, 23 Aug 2017 19:24:39 +0200 Subject: [PATCH 3/3] fix linting --- src/actions/breakpoints.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/breakpoints.js b/src/actions/breakpoints.js index 4c1c1961f6..ec022c7cf3 100644 --- a/src/actions/breakpoints.js +++ b/src/actions/breakpoints.js @@ -291,7 +291,7 @@ export function setBreakpointCondition( await dispatch(enableBreakpoint(location)); bp.disabled = !bp.disabled; } - + await client.setBreakpointCondition( bp.id, location,