Browse Source

Add test for continue

Jeremy Tuloup 5 years ago
parent
commit
ced63227e3
1 changed files with 35 additions and 14 deletions
  1. 35 14
      tests/src/session.spec.ts

+ 35 - 14
tests/src/session.spec.ts

@@ -180,21 +180,25 @@ describe('protocol', () => {
     });
   });
 
-  describe('#variablesReference', () => {
+  const getVariables = async () => {
+    const stackFramesReply = await debugSession.sendRequest('stackTrace', {
+      threadId
+    });
+    const frameId = stackFramesReply.body.stackFrames[0].id;
+    const scopesReply = await debugSession.sendRequest('scopes', {
+      frameId
+    });
+    const scopes = scopesReply.body.scopes;
+    const variablesReference = scopes[0].variablesReference;
+    const variablesReply = await debugSession.sendRequest('variables', {
+      variablesReference
+    });
+    return variablesReply.body.variables;
+  };
+
+  describe('#variables', () => {
     it('should return the variables and their values', async () => {
-      const stackFramesReply = await debugSession.sendRequest('stackTrace', {
-        threadId
-      });
-      const frameId = stackFramesReply.body.stackFrames[0].id;
-      const scopesReply = await debugSession.sendRequest('scopes', {
-        frameId
-      });
-      const scopes = scopesReply.body.scopes;
-      const variablesReference = scopes[0].variablesReference;
-      const variablesReply = await debugSession.sendRequest('variables', {
-        variablesReference
-      });
-      const variables = variablesReply.body.variables;
+      const variables = await getVariables();
       expect(variables.length).to.be.greaterThan(0);
       const i = find(variables, variable => variable.name === 'i');
       expect(i).to.exist;
@@ -202,4 +206,21 @@ describe('protocol', () => {
       expect(i.value).to.equal('1');
     });
   });
+
+  describe('#continue', () => {
+    it('should proceed to the next breakpoint', async () => {
+      await debugSession.sendRequest('continue', { threadId });
+
+      const variables = await getVariables();
+      const i = find(variables, variable => variable.name === 'i');
+      expect(i).to.exist;
+      expect(i.type).to.equal('int');
+      expect(i.value).to.equal('2');
+
+      const j = find(variables, variable => variable.name === 'j');
+      expect(j).to.exist;
+      expect(j.type).to.equal('int');
+      expect(j.value).to.equal('4');
+    });
+  });
 });