diff options
-rw-r--r-- | lib/output/__tests__/website.js | 9 | ||||
-rw-r--r-- | testing/setup.js | 13 |
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/output/__tests__/website.js b/lib/output/__tests__/website.js index 9675e30..2c7ff58 100644 --- a/lib/output/__tests__/website.js +++ b/lib/output/__tests__/website.js @@ -31,14 +31,17 @@ describe('WebsiteGenerator', function() { }); it('should generate a GLOSSARY.html', function() { - console.log(fs.readdirSync(folder)); expect(folder).toHaveFile('GLOSSARY.html'); }); - it('should correctly resolve glossary links', function() { + it('should correctly resolve glossary links in README', function() { var html = fs.readFileSync(folder + '/index.html', 'utf8'); + expect(html).toHaveDOMElement('.page-inner a[href="GLOSSARY.html#hello"]'); + }); - console.log(html); + it('should correctly resolve glossary links in directory', function() { + var html = fs.readFileSync(folder + '/folder/page.html', 'utf8'); + expect(html).toHaveDOMElement('.page-inner a[href="../GLOSSARY.html#hello"]'); }); }); diff --git a/testing/setup.js b/testing/setup.js index b91a299..59fef77 100644 --- a/testing/setup.js +++ b/testing/setup.js @@ -2,6 +2,7 @@ var is = require('is'); var path = require('path'); var fs = require('fs'); var expect = require('expect'); +var cheerio = require('cheerio'); expect.extend({ /** @@ -43,6 +44,18 @@ expect.extend({ 'expected to be defined' ); return this; + }, + + /** + Check that a dom element exists in HTML + + @param {String} selector + */ + toHaveDOMElement: function(selector) { + var $ = cheerio.load(this.actual); + var $el = $(selector); + + expect.assert($el.length > 0, 'expected HTML to contains %s', selector); } }); |