diff options
| author | Vojta Jina | 2013-10-17 14:16:32 -0700 | 
|---|---|---|
| committer | Igor Minar | 2013-10-18 15:35:41 -0700 | 
| commit | e8cc85f733a49ca53e8cda5a96bbaacc9a20ac7e (patch) | |
| tree | f145db33b29ee9cce531492a8332adc537033b70 /docs/spec/ngdocSpec.js | |
| parent | c22adbf160f32c1839fbb35382b7a8c6bcec2927 (diff) | |
| download | angular.js-e8cc85f733a49ca53e8cda5a96bbaacc9a20ac7e.tar.bz2 | |
chore(docs): generate header ids for better linking
- generate ids for all headers
- collect defined anchors
- check broken links (even if the page exists, but the anchor/id does not)
Diffstat (limited to 'docs/spec/ngdocSpec.js')
| -rw-r--r-- | docs/spec/ngdocSpec.js | 52 | 
1 files changed, 28 insertions, 24 deletions
| diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js index 607745d8..15fd0ba4 100644 --- a/docs/spec/ngdocSpec.js +++ b/docs/spec/ngdocSpec.js @@ -262,33 +262,37 @@ describe('ngdoc', function() {        expect(docs[0].events).toEqual([eventA, eventB]);        expect(docs[0].properties).toEqual([propA, propB]);      }); +  }); +  describe('checkBrokenLinks', function() { +    var docs; -    describe('links checking', function() { -      var docs; -      beforeEach(function() { -        spyOn(console, 'log'); -        docs = [new Doc({section: 'api', id: 'fake.id1', links: ['non-existing-link']}), -                new Doc({section: 'api', id: 'fake.id2'}), -                new Doc({section: 'api', id: 'fake.id3'})]; -      }); - -      it('should log warning when any link doesn\'t exist', function() { -        ngdoc.merge(docs); -        expect(console.log).toHaveBeenCalled(); -        expect(console.log.argsForCall[0][0]).toContain('WARNING:'); -      }); +    beforeEach(function() { +      spyOn(console, 'log'); +      docs = [new Doc({section: 'api', id: 'fake.id1', anchors: ['one']}), +              new Doc({section: 'api', id: 'fake.id2'}), +              new Doc({section: 'api', id: 'fake.id3'})]; +    }); -      it('should say which link doesn\'t exist', function() { -        ngdoc.merge(docs); -        expect(console.log.argsForCall[0][0]).toContain('non-existing-link'); -      }); +    it('should log warning when a linked page does not exist', function() { +      docs.push(new Doc({section: 'api', id: 'with-broken.link', links: ['non-existing-link']})) +      ngdoc.checkBrokenLinks(docs); +      expect(console.log).toHaveBeenCalled(); +      var warningMsg = console.log.argsForCall[0][0] +      expect(warningMsg).toContain('WARNING:'); +      expect(warningMsg).toContain('non-existing-link'); +      expect(warningMsg).toContain('api/with-broken.link'); +    }); -      it('should say where is the non-existing link', function() { -        ngdoc.merge(docs); -        expect(console.log.argsForCall[0][0]).toContain('api/fake.id1'); -      }); +    it('should log warning when a linked anchor does not exist', function() { +      docs.push(new Doc({section: 'api', id: 'with-broken.link', links: ['api/fake.id1#non-existing']})) +      ngdoc.checkBrokenLinks(docs); +      expect(console.log).toHaveBeenCalled(); +      var warningMsg = console.log.argsForCall[0][0] +      expect(warningMsg).toContain('WARNING:'); +      expect(warningMsg).toContain('non-existing'); +      expect(warningMsg).toContain('api/with-broken.link');      });    }); @@ -524,7 +528,7 @@ describe('ngdoc', function() {          doc.ngdoc = 'filter';          doc.parse();          expect(doc.html()).toContain( -            '<h3 id="Animations">Animations</h3>\n' + +            '<h3 id="usage_animations">Animations</h3>\n' +              '<div class="animations">' +                '<ul>' +                  '<li>enter - Add text</li>' + @@ -541,7 +545,7 @@ describe('ngdoc', function() {          var doc = new Doc('@ngdoc overview\n@name angular\n@description\n#heading\ntext');          doc.parse();          expect(doc.html()).toContain('text'); -        expect(doc.html()).toContain('<h2>heading</h2>'); +        expect(doc.html()).toContain('<h2 id="heading">heading</h2>');          expect(doc.html()).not.toContain('Description');        });      }); | 
