var extractor = require('../../extractors/jsdoc');

var srcJsContent = require('./_test-data/srcJsFile.js');
var docsFromJsContent = require('./_test-data/docsFromJsFile');

describe("js doc extractor", function() {
  describe("pattern", function() {
    it("should only match js files", function() {
      expect(extractor.pattern.test('abc.js')).toBeTruthy();
      expect(extractor.pattern.test('abc.ngdoc')).toBeFalsy();
    });
  });
  describe("process", function() {
    it('should return a collection of documents extracted from the file', function() {
      var docs = extractor.processFile('some/file.js', srcJsContent);
      expect(docs.length).toEqual(3);
      expect(docs[0]).toEqual(jasmine.objectContaining(docsFromJsContent[0]));
      expect(docs[1]).toEqual(jasmine.objectContaining(docsFromJsContent[1]));
      expect(docs[2]).toEqual(jasmine.objectContaining(docsFromJsContent[2]));
    });

    it("should ignore non-jsdoc comments", function() {
      var docs = extractor.processFile('some/file.js', '/** Some jsdoc comment */\n// A line comment\n\/* A non-jsdoc block comment*/');
      expect(docs.length).toEqual(1);
    });

    it("should find the next code item following the comment and attach it to the doc", function() {
      var docs = extractor.processFile('some/file.js', srcJsContent);
      expect(docs.length).toEqual(3);
      expect(docs[0].code.node.type).toEqual('FunctionDeclaration');
      expect(docs[1].code.node.type).toEqual('ExpressionStatement');
      expect(docs[2].code.node.type).toEqual('ReturnStatement');
    });
  });
});
@@ -209,16 +209,17 @@
 ion() %7B%0A
+%0A
   descri
@@ -433,16 +433,18 @@
 ;%0A  %7D);%0A
+%0A%0A
   descri
@@ -466,24 +466,25 @@
 unction() %7B%0A
+%0A
     it('shou
@@ -904,32 +904,329 @@
 %5B2%5D));%0A    %7D);%0A%0A
+%0A    it(%22should strip off the leading whitespace/stars from each line of the comments%22, function() %7B%0A      var docs = extractor.processFile('some/file.js', '/** abc  %5Cn  * other stuff  %5Cn%5Ct%5Ct*last line.%5Cn*/%5Cn');%0A      expect(docs%5B0%5D.content).toEqual('abc  %5Cnother stuff  %5Cnlast line.');%0A    %7D);%0A%0A%0A
     it(%22should i
@@ -1440,16 +1440,16 @@
 ual(1);%0A
-
     %7D);%0A
@@ -1449,16 +1449,17 @@
    %7D);%0A%0A
+%0A
     it(%22

test whitespace/star stripping