Просмотр исходного кода

Merge pull request #170 from jtpio/source-test

Add tests for source and loadedSources
Johan Mabille 5 лет назад
Родитель
Сommit
936d7a6b04
1 измененных файлов с 24 добавлено и 0 удалено
  1. 24 0
      tests/src/session.spec.ts

+ 24 - 0
tests/src/session.spec.ts

@@ -262,4 +262,28 @@ describe('protocol', () => {
       expect(j.value).to.equal('4');
     });
   });
+
+  describe('#loadedSources', () => {
+    it('should *not* retrieve the list of loaded sources', async () => {
+      // `loadedSources` is not supported at the moment "unknown command"
+      const reply = await debugSession.sendRequest('loadedSources', {});
+      expect(reply.success).to.be.false;
+    });
+  });
+
+  describe('#source', () => {
+    it('should retrieve the source of the dumped code cell', async () => {
+      const stackFramesReply = await debugSession.sendRequest('stackTrace', {
+        threadId
+      });
+      const frame = stackFramesReply.body.stackFrames[0];
+      const source = frame.source;
+      const reply = await debugSession.sendRequest('source', {
+        source: { path: source.path },
+        sourceReference: source.sourceReference
+      });
+      const sourceCode = reply.body.content;
+      expect(sourceCode).to.equal(code);
+    });
+  });
 });