diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-05-26 21:37:10 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-05-26 21:37:10 +0200 |
commit | 901328f247388198fff77f411377206222c89390 (patch) | |
tree | b260d737ab759916f9123f302468301d34064f12 | |
parent | b47ebaa9d91ecc0a1a1678eb8da79837a3cfee19 (diff) | |
download | gitbook-901328f247388198fff77f411377206222c89390.zip gitbook-901328f247388198fff77f411377206222c89390.tar.gz gitbook-901328f247388198fff77f411377206222c89390.tar.bz2 |
Complete basic tests for glossary
-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); } }); |