describe('type annotation error reporting', function() {
    const sinon = createSinonSuite(this);

    it('reports the line of the comment in file', function() {
      sinon.spy(NullLinter, 'logRuleEntry')

      parse(function() {;
        // /**
        //  * @property {(Object) -> Object} foo
        //  */
      }, {}, {
        commentNode: {
          loc: {
            start: {
              line: 3
            }
          }
        }
      });

      // assert.ok(tag.invalid)
      assert.calledWith(NullLinter.logRuleEntry, sinon.match({
        rule: TypeExpressions,
        params: sinon.match({
          typeString: '(Object) -> Object'
        })
      }))
    })
  })
describe("LinkResolver__MegadocLinkStrategy", function() {
  var sinon = createSinonSuite(this);

  [
    // works with no text
    {
      text: '[Foo]()',
      calls: [
        { path: 'Foo' }
      ]
    },

    // works with custom texts
    {
      text: '[Foo bar]()',
      calls: [{ path: 'Foo', text: 'bar'}]
    },

    // works with multiple matches
    {
      text: 'Gone to the [zoo]() where [monkeys]() hang out.',
      calls: [
        { path: 'zoo' },
        { path: 'monkeys' }
      ]
    },

    // ignores external links
    {
      text: 'Gone to the [zoo](http://google.com).',
      calls: [
      ]
    },
    // ignores external links with multiple words
    {
      text: 'Gone to the [super zoo](http://google.com).',
      calls: [
      ]
    }
  ].forEach(function(spec) {
    it('works with "' + spec.text + '"', function() {
      var onResolve = sinon.stub();

      subject(spec.text, onResolve);

      assert.callCount(onResolve, spec.calls.length);

      spec.calls.forEach(function(callSpec, callIndex) {
        assert.include(onResolve.getCall(callIndex).args[0], callSpec);
      });
    });
  });
});
describe('megadoc-compiler::composeTree', function() {
  const subject = composeTree;
  const sinon = createSinonSuite(this);

  describe('CHANGE_NODE_PARENT', function() {
    it('maps a DocumentEntity to a Document', function() {
      const documents = [
        b.document({
          id: 'Klass'
        }),
        b.documentEntity({
          id: 'Method',
        })
      ]
      const tree = subject({
        id: 'foo',
        documents,
        treeOperations: [
          {
            type: 'CHANGE_NODE_PARENT',
            data: {
              parentUid: uidOf('Klass', documents),
              uid: uidOf('Method', documents),
            },
          }
        ]
      })

      assert.equal(tree.documents.length, 1)
      assert.equal(tree.documents[0].id, 'Klass')
      assert.equal(tree.documents[0].entities.length, 1)
      assert.equal(tree.documents[0].entities[0].id, 'Method')
    });

    it('maps a Document to a Document', function() {
      const documents = [
        b.document({ id: 'Container' }),
        b.document({ id: 'Klass' })
      ];
      const tree = subject({
        id: 'foo',
        documents,
        treeOperations: [
          {
            type: 'CHANGE_NODE_PARENT',
            data: {
              uid: uidOf('Klass', documents),
              parentUid: uidOf('Container', documents),
            },
          }
        ]
      })

      assert.equal(tree.documents.length, 1)
      assert.equal(tree.documents[0].id, 'Container')
      assert.equal(tree.documents[0].documents.length, 1)
      assert.equal(tree.documents[0].documents[0].id, 'Klass')
    });

    it('whines if a parent could not be found', function() {
      sinon.spy(NullLinter, 'logError');

      const documents = [
        b.document({
          id: 'Klass'
        })
      ];

      subject({
        id: 'foo',
        documents,
        linter: NullLinter,
        treeOperations: [
          {
            type: 'CHANGE_NODE_PARENT',
            data: {
              uid: uidOf('Klass', documents),
              parentUid: uidOf('Container', documents),
            },
          }
        ]
      })

      assert.calledWith(NullLinter.logError, sinon.match({
        message: sinon.match(/Node with UID ".+" specified as a parent for node ".+" could not be found./)
      }))
    });

    it('whines if the node could not be found', function() {
      sinon.spy(NullLinter, 'logError');

      const documents = [
        b.document({
          id: 'Klass',
        })
      ];

      subject({
        id: 'foo',
        documents,
        linter: NullLinter,
        treeOperations: [
          {
            type: 'CHANGE_NODE_PARENT',
            data: {
              uid: uidOf('Child', documents),
              parentUid: uidOf('Klass', documents),
            },
          }
        ]
      })

      assert.calledWith(NullLinter.logError, sinon.match({
        message: sinon.match(/Node with UID ".+" specified as a child for node ".+" could not be found./)
      }))
    });
  })
});