debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[stepping] add some unit tests

Open jasonLaster opened this issue 9 years ago • 2 comments

It would be great to boost our coverage of src/actions/pause

diff --git a/src/actions/tests/pause.spec.js b/src/actions/tests/pause.spec.js
index 46c5b3c..58708e3 100644
--- a/src/actions/tests/pause.spec.js
+++ b/src/actions/tests/pause.spec.js
@@ -22,15 +22,15 @@ const mockThreadClient = {
   }
 };

+const mockPauseInfo = {
+  frames: [{ id: 1, scope: [], location: { sourceId: "foo1", line: 4 } }],
+  loadedObjects: [],
+  why: {}
+};
+
 describe("pause", () => {
   it("should set and clear the command", async () => {
     const { dispatch, getState } = createStore(mockThreadClient);
-    const mockPauseInfo = {
-      frames: [{ id: 1, scope: [], location: { sourceId: "foo1", line: 4 } }],
-      loadedObjects: [],
-      why: {}
-    };
-
     await dispatch(actions.paused(mockPauseInfo));
     dispatch(actions.stepIn());
     expect(isStepping(getState())).toBeTruthy();
@@ -46,4 +46,21 @@ describe("pause", () => {
     await dispatch(actions.resumed());
     expect(client.evaluate.mock.calls.length).toEqual(0);
   });
+
+  it("should only step when paused", async () => {
+    const client = { stepIn: jest.fn() };
+    const { dispatch } = createStore(client);
+
+    dispatch(actions.stepIn());
+    expect(client.stepIn.calls.length).toEqual(0);
+  });
+
+  it("should step when paused", async () => {
+    const client = { stepIn: jest.fn() };
+    const { dispatch } = createStore(client);
+
+    await dispatch(actions.paused(mockPauseInfo));
+    dispatch(actions.stepIn());
+    expect(client.stepIn.calls.length).toEqual(1);
+  });

jasonLaster avatar Aug 17 '17 16:08 jasonLaster

/claim

James300 avatar Nov 09 '17 22:11 James300

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Nov 09 '17 22:11 claim