diff options
-rw-r--r-- | test/assertions.js | 32 | ||||
-rw-r--r-- | test/codehighlighting.js | 26 | ||||
-rw-r--r-- | test/configuration.js | 19 | ||||
-rw-r--r-- | test/conrefs.js | 16 | ||||
-rw-r--r-- | test/ebook.js | 24 | ||||
-rw-r--r-- | test/git.js | 12 | ||||
-rw-r--r-- | test/glossary.js | 30 | ||||
-rw-r--r-- | test/helper.js | 22 | ||||
-rw-r--r-- | test/images.js | 26 | ||||
-rw-r--r-- | test/init.js | 22 | ||||
-rw-r--r-- | test/json.js | 32 | ||||
-rw-r--r-- | test/languages.js | 13 | ||||
-rw-r--r-- | test/links.js | 30 | ||||
-rw-r--r-- | test/navigation.js | 44 | ||||
-rw-r--r-- | test/plugins/replace_highlight/index.js | 2 | ||||
-rw-r--r-- | test/resolve.js | 55 | ||||
-rw-r--r-- | test/summary.js | 24 | ||||
-rw-r--r-- | test/templating.js | 14 | ||||
-rw-r--r-- | test/website.js | 11 |
19 files changed, 219 insertions, 235 deletions
diff --git a/test/assertions.js b/test/assertions.js index f81645b..7e14ecb 100644 --- a/test/assertions.js +++ b/test/assertions.js @@ -1,27 +1,27 @@ -var _ = require('lodash'); -var fs = require('fs'); -var path = require('path'); -var should = require('should'); -var cheerio = require('cheerio'); +var _ = require("lodash"); +var fs = require("fs"); +var path = require("path"); +var should = require("should"); +var cheerio = require("cheerio"); -should.Assertion.add('file', function(file, description) { - this.params = { actual: this.obj.toString(), operator: 'have file ' + file, message: description }; +should.Assertion.add("file", function(file, description) { + this.params = { actual: this.obj.toString(), operator: "have file " + file, message: description }; - this.obj.should.have.property('options').which.is.an.Object; - this.obj.options.should.have.property('output').which.is.a.String; + this.obj.should.have.property("options").which.is.an.Object(); + this.obj.options.should.have.property("output").which.is.a.String(); this.assert(fs.existsSync(path.resolve(this.obj.options.output, file))); }); -should.Assertion.add('jsonfile', function(file, description) { - this.params = { actual: this.obj.toString(), operator: 'have valid jsonfile ' + file, message: description }; +should.Assertion.add("jsonfile", function(file, description) { + this.params = { actual: this.obj.toString(), operator: "have valid jsonfile " + file, message: description }; - this.obj.should.have.property('options').which.is.an.Object; - this.obj.options.should.have.property('output').which.is.a.String; + this.obj.should.have.property("options").which.is.an.Object(); + this.obj.options.should.have.property("output").which.is.a.String(); this.assert(JSON.parse(fs.readFileSync(path.resolve(this.obj.options.output, file), { encoding: "utf-8" }))); }); -should.Assertion.add('html', function(rules, description) { - this.params = { actual: "HTML string", operator: 'valid html', message: description }; +should.Assertion.add("html", function(rules, description) { + this.params = { actual: "HTML string", operator: "valid html", message: description }; var $ = cheerio.load(this.obj); _.each(rules, function(validations, query) { @@ -60,7 +60,7 @@ should.Assertion.add('html', function(rules, description) { // Test attributes _.each(validations.attributes, function(value, name) { var attr = $el.attr(name); - should(attr).be.ok; + should(attr).be.ok(); attr.should.be.equal(value); }); }); diff --git a/test/codehighlighting.js b/test/codehighlighting.js index e35f37e..d79fc85 100644 --- a/test/codehighlighting.js +++ b/test/codehighlighting.js @@ -1,16 +1,14 @@ -var _ = require('lodash'); -var should = require('should'); -var path = require('path'); -var fs = require('fs'); +var path = require("path"); +var fs = require("fs"); -var Plugin = require('../lib/plugin'); -var PLUGINS_ROOT = path.resolve(__dirname, 'plugins'); +var Plugin = require("../lib/plugin"); +var PLUGINS_ROOT = path.resolve(__dirname, "plugins"); -describe('Code Highlighting', function () { +describe("Code Highlighting", function () { var book, PAGE; before(function() { - return books.generate('highlight', 'website', { + return books.generate("highlight", "website", { prepare: function(_book) { book = _book; @@ -28,29 +26,29 @@ describe('Code Highlighting', function () { }); }); - it('should correctly replace highlighting', function() { + it("should correctly replace highlighting", function() { PAGE.should.be.html({ "code": { index: 0, - text: 'code_test 1\n_code' + text: "code_test 1\n_code" } }); }); - it('should correctly replace highlighting with language', function() { + it("should correctly replace highlighting with language", function() { PAGE.should.be.html({ "code": { index: 1, - text: 'lang_test 2\n_lang' + text: "lang_test 2\n_lang" } }); }); - it('should correctly replace highlighting for inline code', function() { + it("should correctly replace highlighting for inline code", function() { PAGE.should.be.html({ "code": { index: 2, - text: 'code_test 3_code' + text: "code_test 3_code" } }); }); diff --git a/test/configuration.js b/test/configuration.js index 2cff26e..c96c10d 100644 --- a/test/configuration.js +++ b/test/configuration.js @@ -1,40 +1,37 @@ -var fs = require('fs'); -var path = require('path'); - -describe('Configuration', function () { - it('should extract default title from README', function() { +describe("Configuration", function () { + it("should extract default title from README", function() { return books.parse("basic") .then(function(book) { book.options.title.should.be.equal("Readme"); }); }); - it('should extract default description from README', function() { + it("should extract default description from README", function() { return books.parse("basic") .then(function(book) { book.options.description.should.be.equal("Default description for the book."); }); }); - it('should correctly load from json (book.json)', function() { + it("should correctly load from json (book.json)", function() { return books.parse("config-json") .then(function(book) { book.options.title.should.be.equal("json-config"); }); }); - it('should correctly load from JavaScript (book.js)', function() { + it("should correctly load from JavaScript (book.js)", function() { return books.parse("config-js") .then(function(book) { book.options.title.should.be.equal("js-config"); }); }); - it('should provide configuration on book.config.get', function() { + it("should provide configuration on book.config.get", function() { return books.parse("basic") .then(function(book) { - book.config.get('description').should.be.equal("Default description for the book."); - book.getConfig('description').should.be.equal("Default description for the book."); + book.config.get("description").should.be.equal("Default description for the book."); + book.getConfig("description").should.be.equal("Default description for the book."); }); }); }); diff --git a/test/conrefs.js b/test/conrefs.js index 7e044f5..4f654b0 100644 --- a/test/conrefs.js +++ b/test/conrefs.js @@ -1,7 +1,7 @@ -var fs = require('fs'); -var path = require('path'); +var fs = require("fs"); +var path = require("path"); -describe('ConRefs', function () { +describe("ConRefs", function () { var book, readme; before(function() { @@ -16,7 +16,7 @@ describe('ConRefs', function () { }); }); - it('should handle local references', function() { + it("should handle local references", function() { readme.should.be.html({ ".page-inner p#t1": { count: 1, @@ -26,7 +26,7 @@ describe('ConRefs', function () { }); }); - it('should handle local references with absolute paths', function() { + it("should handle local references with absolute paths", function() { readme.should.be.html({ ".page-inner p#t2": { count: 1, @@ -36,7 +36,7 @@ describe('ConRefs', function () { }); }); - it('should correctly include file from git reference', function() { + it("should correctly include file from git reference", function() { readme.should.be.html({ ".page-inner p#t3": { count: 1, @@ -46,7 +46,7 @@ describe('ConRefs', function () { }); }); - it('should correctly handle deep include in git reference', function() { + it("should correctly handle deep include in git reference", function() { readme.should.be.html({ ".page-inner p#t4": { count: 1, @@ -56,7 +56,7 @@ describe('ConRefs', function () { }); }); - it('should correctly handle absolute include in git reference', function() { + it("should correctly handle absolute include in git reference", function() { readme.should.be.html({ ".page-inner p#t5": { count: 1, diff --git a/test/ebook.js b/test/ebook.js index 033fd04..b065ae7 100644 --- a/test/ebook.js +++ b/test/ebook.js @@ -1,8 +1,8 @@ -var fs = require('fs'); -var path = require('path'); +var fs = require("fs"); +var path = require("path"); -describe('eBook generator', function () { - describe('Basic Book', function() { +describe("eBook generator", function () { + describe("Basic Book", function() { var book; before(function() { @@ -12,17 +12,17 @@ describe('eBook generator', function () { }); }); - it('should correctly output a SUMMARY.html', function() { + it("should correctly output a SUMMARY.html", function() { book.should.have.file("SUMMARY.html"); }); - it('should correctly copy assets', function() { + it("should correctly copy assets", function() { book.should.have.file("gitbook"); book.should.have.file("gitbook/style.css"); }); }); - describe('Custom styles', function() { + describe("Custom styles", function() { var book; before(function() { @@ -32,7 +32,7 @@ describe('eBook generator', function () { }); }); - it('should remove default print.css', function() { + it("should remove default print.css", function() { var PAGE = fs.readFileSync( path.join(book.options.output, "index.html"), { encoding: "utf-8" } @@ -46,21 +46,21 @@ describe('eBook generator', function () { }); PAGE.should.be.html({ - "link[href='./styles/print.css']": { + "link[href=\"./styles/print.css\"]": { count: 1 } }); PAGE.should.be.html({ - "link[href='gitbook/plugins/gitbook-plugin-highlight/ebook.css']": { + "link[href=\"gitbook/plugins/gitbook-plugin-highlight/ebook.css\"]": { count: 1 } }); }); - it('should correctly print.css', function() { + it("should correctly print.css", function() { book.should.have.file("styles"); book.should.have.file("styles/print.css"); }); - }) + }); }); diff --git a/test/git.js b/test/git.js index f03bec2..6fd6b41 100644 --- a/test/git.js +++ b/test/git.js @@ -1,8 +1,8 @@ -var should = require('should'); -var git = require('../lib/utils/git'); +var should = require("should"); +var git = require("../lib/utils/git"); -describe('GIT parser and getter', function () { - it('should correctly parse an https url', function() { +describe("GIT parser and getter", function () { + it("should correctly parse an https url", function() { var parts = git.parseUrl("git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md"); should.exist(parts); @@ -11,7 +11,7 @@ describe('GIT parser and getter', function () { parts.filepath.should.be.equal("test.md"); }); - it('should correctly parse an https url with a reference', function() { + it("should correctly parse an https url with a reference", function() { var parts = git.parseUrl("git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md#0.1.2"); should.exist(parts); @@ -20,7 +20,7 @@ describe('GIT parser and getter', function () { parts.filepath.should.be.equal("test.md"); }); - it('should correctly parse an ssh url', function() { + it("should correctly parse an ssh url", function() { var parts = git.parseUrl("git+git@github.com:GitbookIO/gitbook.git/directory/README.md#e1594cde2c32e4ff48f6c4eff3d3d461743d74e1"); should.exist(parts); diff --git a/test/glossary.js b/test/glossary.js index fb573d9..f0f31a5 100644 --- a/test/glossary.js +++ b/test/glossary.js @@ -1,8 +1,8 @@ -var fs = require('fs'); -var path = require('path'); +var fs = require("fs"); +var path = require("path"); -describe('Glossary', function () { - describe('Parsing', function() { +describe("Glossary", function () { + describe("Parsing", function() { var book; before(function() { @@ -12,13 +12,13 @@ describe('Glossary', function () { }); }); - it('should correctly list items', function() { + it("should correctly list items", function() { book.should.have.property("glossary"); book.glossary.should.have.lengthOf(3); }); }); - describe('Generation', function() { + describe("Generation", function() { var book; before(function() { @@ -28,11 +28,11 @@ describe('Glossary', function () { }); }); - it('should correctly generate a GLOSSARY.html', function() { + it("should correctly generate a GLOSSARY.html", function() { book.should.have.file("GLOSSARY.html"); }); - describe('Page Integration', function() { + describe("Page Integration", function() { var readme, page; before(function() { @@ -46,9 +46,9 @@ describe('Glossary', function () { ); }); - it('should correctly replaced terms by links', function() { + it("should correctly replaced terms by links", function() { readme.should.be.html({ - ".page-inner a[href='GLOSSARY.html#test']": { + ".page-inner a[href=\"GLOSSARY.html#test\"]": { count: 1, text: "test", attributes: { @@ -58,15 +58,15 @@ describe('Glossary', function () { }); }); - it('should correctly replaced terms by links (relative)', function() { + it("should correctly replaced terms by links (relative)", function() { page.should.be.html({ - ".page-inner a[href='../GLOSSARY.html#test']": { + ".page-inner a[href=\"../GLOSSARY.html#test\"]": { count: 1 } }); }); - it('should not replace terms in codeblocks', function() { + it("should not replace terms in codeblocks", function() { readme.should.be.html({ ".page-inner code a": { count: 0 @@ -74,9 +74,9 @@ describe('Glossary', function () { }); }); - it('should correctly select the longest term', function() { + it("should correctly select the longest term", function() { readme.should.be.html({ - ".page-inner a[href='GLOSSARY.html#test_long']": { + ".page-inner a[href=\"GLOSSARY.html#test_long\"]": { count: 1, text: "test long" } diff --git a/test/helper.js b/test/helper.js index f4432a9..95619df 100644 --- a/test/helper.js +++ b/test/helper.js @@ -1,13 +1,11 @@ -var os = require('os'); -var path = require('path'); -var Q = require('q'); -var fs = require('fs'); -var _ = require('lodash'); -var should = require('should'); +var os = require("os"); +var path = require("path"); +var Q = require("q"); +var _ = require("lodash"); -var fsUtil = require('../lib/utils/fs'); -var Book = require('../').Book; -var LOG_LEVELS = require('../').LOG_LEVELS; +var fsUtil = require("../lib/utils/fs"); +var Book = require("../").Book; +var LOG_LEVELS = require("../").LOG_LEVELS; require("./assertions"); @@ -61,16 +59,14 @@ global.books = { // Cleanup all tests after(function() { return _.chain(BOOKS) - .map(function(types, bookId) { + .map(function(types) { return _.values(types); }) .flatten() .reduce(function(prev, book) { return prev.then(function() { return fsUtil.remove(book.options.output); - }) + }); }, Q()) .value(); }); - - diff --git a/test/images.js b/test/images.js index 75bc529..de45066 100644 --- a/test/images.js +++ b/test/images.js @@ -1,9 +1,9 @@ -var fs = require('fs'); -var _ = require('lodash'); -var path = require('path'); -var cheerio = require('cheerio'); +var fs = require("fs"); +var _ = require("lodash"); +var path = require("path"); +var cheerio = require("cheerio"); -describe('Images', function () { +describe("Images", function () { var book, readme, $, $img, srcs; before(function() { @@ -17,38 +17,40 @@ describe('Images', function () { ); $ = cheerio.load(readme); $img = $("img"); - srcs = $img.map(function() { return $(this).attr("src"); }) + srcs = $img.map(function() { + return $(this).attr("src"); + }); }); }); - it('should detect all images', function() { + it("should detect all images", function() { _.uniq(srcs).should.have.lengthOf(4); }); - it('should keep image tags', function() { + it("should keep image tags", function() { srcs.should.have.lengthOf(5); }); - it('should not have .svg files', function() { + it("should not have .svg files", function() { _.each(srcs, function(src) { path.extname(src).should.not.equal(".svg"); }); }); - it('should correctly convert svg images to png', function() { + it("should correctly convert svg images to png", function() { _.each(srcs, function(src) { book.should.have.file(src); }); }); - it('should handle relative paths', function() { + it("should handle relative paths", function() { var PAGE = fs.readFileSync( path.join(book.options.output, "folder/PAGE.html"), { encoding: "utf-8" } ); PAGE.should.be.html({ - "img[src='../test.png']": { + "img[src=\"../test.png\"]": { count: 1 } }); diff --git a/test/init.js b/test/init.js index 8415b20..7e5ffee 100644 --- a/test/init.js +++ b/test/init.js @@ -1,11 +1,11 @@ -var fs = require('fs'); -var path = require('path'); -var should = require('should'); +var fs = require("fs"); +var path = require("path"); +var should = require("should"); -var Book = require('../').Book; -var LOG_LEVELS = require('../').LOG_LEVELS; +var Book = require("../").Book; +var LOG_LEVELS = require("../").LOG_LEVELS; -describe('Init Books', function () { +describe("Init Books", function () { var initRoot; before(function() { @@ -15,10 +15,10 @@ describe('Init Books', function () { }); }); - it('should create all chapters', function() { - should(fs.existsSync(path.resolve(initRoot, "hello.md"))).be.ok; - should(fs.existsSync(path.resolve(initRoot, "hello2.md"))).be.ok; - should(fs.existsSync(path.resolve(initRoot, "hello3/hello4.md"))).be.ok; - should(fs.existsSync(path.resolve(initRoot, "hello3/hello5/hello6.md"))).be.ok; + it("should create all chapters", function() { + should(fs.existsSync(path.resolve(initRoot, "hello.md"))).be.ok(); + should(fs.existsSync(path.resolve(initRoot, "hello2.md"))).be.ok(); + should(fs.existsSync(path.resolve(initRoot, "hello3/hello4.md"))).be.ok(); + should(fs.existsSync(path.resolve(initRoot, "hello3/hello5/hello6.md"))).be.ok(); }); }); diff --git a/test/json.js b/test/json.js index 758cfd7..311c80a 100644 --- a/test/json.js +++ b/test/json.js @@ -1,8 +1,8 @@ -var fs = require('fs'); -var path = require('path'); +var fs = require("fs"); +var path = require("path"); -describe('JSON generator', function () { - describe('Basic Book', function() { +describe("JSON generator", function () { + describe("Basic Book", function() { var book; before(function() { @@ -12,15 +12,15 @@ describe('JSON generator', function () { }); }); - it('should correctly output a README.json', function() { + it("should correctly output a README.json", function() { book.should.have.file("README.json"); }); - it('should output a valid json', function() { + it("should output a valid json", function() { book.should.have.jsonfile("README.json"); }); - describe('Page Format', function() { + describe("Page Format", function() { var page; before(function() { @@ -32,25 +32,25 @@ describe('JSON generator', function () { ); }); - it('should contains valid section', function() { + it("should contains valid section", function() { page.should.have.property("sections").with.lengthOf(1); - page.sections[0].should.have.property("content").which.is.a.String; + page.sections[0].should.have.property("content").which.is.a.String(); page.sections[0].should.have.property("type", "normal"); }); - it('should contains valid progress', function() { + it("should contains valid progress", function() { page.should.have.property("progress"); page.progress.should.have.property("chapters").with.lengthOf(1); page.progress.should.have.property("current"); }); - it('should contains no languages', function() { + it("should contains no languages", function() { page.should.have.property("langs").with.lengthOf(0); }); }); }); - describe('Multilingual Book', function() { + describe("Multilingual Book", function() { var book; before(function() { @@ -60,19 +60,19 @@ describe('JSON generator', function () { }); }); - it('should correctly output READMEs', function() { + it("should correctly output READMEs", function() { book.should.have.file("README.json"); book.should.have.file("en/README.json"); book.should.have.file("fr/README.json"); }); - it('should output valid json', function() { + it("should output valid json", function() { book.should.have.jsonfile("README.json"); book.should.have.jsonfile("en/README.json"); book.should.have.jsonfile("fr/README.json"); }); - describe('Page Format', function() { + describe("Page Format", function() { var page; before(function() { @@ -84,7 +84,7 @@ describe('JSON generator', function () { ); }); - it('should contains no languages', function() { + it("should contains no languages", function() { page.should.have.property("langs").with.lengthOf(2); }); }); diff --git a/test/languages.js b/test/languages.js index abdc5dd..0bde347 100644 --- a/test/languages.js +++ b/test/languages.js @@ -1,8 +1,5 @@ -var fs = require('fs'); -var path = require('path'); - -describe('Languages', function () { - describe('Parsing', function() { +describe("Languages", function () { + describe("Parsing", function() { var book; before(function() { @@ -12,7 +9,7 @@ describe('Languages', function () { }); }); - it('should correctly list languages', function() { + it("should correctly list languages", function() { book.should.have.property("books"); book.books.should.have.lengthOf(2); @@ -21,7 +18,7 @@ describe('Languages', function () { }); }); - describe('Generation', function() { + describe("Generation", function() { var book; before(function() { @@ -31,7 +28,7 @@ describe('Languages', function () { }); }); - it('should correctly create books', function() { + it("should correctly create books", function() { book.should.have.file("index.html"); book.should.have.file("en/index.html"); book.should.have.file("fr/index.html"); diff --git a/test/links.js b/test/links.js index 1d83511..baca9d1 100644 --- a/test/links.js +++ b/test/links.js @@ -1,13 +1,11 @@ -var should = require('should'); -var fs = require('fs'); -var _ = require('lodash'); -var path = require('path'); -var cheerio = require('cheerio'); +var fs = require("fs"); +var path = require("path"); +var cheerio = require("cheerio"); var links = require("../lib/utils/links"); -describe('Links', function () { - it('should correctly test external links', function() { +describe("Links", function () { + it("should correctly test external links", function() { links.isExternal("http://google.fr").should.be.exactly(true); links.isExternal("https://google.fr").should.be.exactly(true); links.isExternal("test.md").should.be.exactly(false); @@ -15,32 +13,32 @@ describe('Links', function () { links.isExternal("/folder/test.md").should.be.exactly(false); }); - it('should correctly detect anchor links', function() { + it("should correctly detect anchor links", function() { links.isAnchor("#test").should.be.exactly(true); links.isAnchor(" #test").should.be.exactly(true); links.isAnchor("https://google.fr#test").should.be.exactly(false); links.isAnchor("test.md#test").should.be.exactly(false); }); - describe('toAbsolute', function() { - it('should correctly transform as absolute', function() { + describe("toAbsolute", function() { + it("should correctly transform as absolute", function() { links.toAbsolute("http://google.fr").should.be.equal("http://google.fr"); links.toAbsolute("test.md", "./", "./").should.be.equal("test.md"); links.toAbsolute("folder/test.md", "./", "./").should.be.equal("folder/test.md"); }); - it('should correctly handle windows path', function() { + it("should correctly handle windows path", function() { links.toAbsolute("folder\\test.md", "./", "./").should.be.equal("folder/test.md"); }); - it('should correctly handle absolute path', function() { + it("should correctly handle absolute path", function() { links.toAbsolute("/test.md", "./", "./").should.be.equal("test.md"); links.toAbsolute("/test.md", "test", "test").should.be.equal("../test.md"); links.toAbsolute("/sub/test.md", "test", "test").should.be.equal("../sub/test.md"); }); }); - describe('page', function() { + describe("page", function() { var book; before(function() { @@ -50,7 +48,7 @@ describe('Links', function () { }); }); - it('should correctly replace relative links', function() { + it("should correctly replace relative links", function() { var readme = fs.readFileSync( path.join(book.options.output, "folder1/index.html"), { encoding: "utf-8" } @@ -58,8 +56,8 @@ describe('Links', function () { var $ = cheerio.load(readme); var $a = $(".page-inner a"); - $a.attr('href').should.be.exactly("../folder2/index.html"); - }) + $a.attr("href").should.be.exactly("../folder2/index.html"); + }); }); }); diff --git a/test/navigation.js b/test/navigation.js index ddcc86e..9118b3c 100644 --- a/test/navigation.js +++ b/test/navigation.js @@ -1,6 +1,6 @@ -var should = require('should'); +var should = require("should"); -describe('Navigation', function () { +describe("Navigation", function () { var book; before(function() { @@ -10,52 +10,52 @@ describe('Navigation', function () { }); }); - it('should correctly parse navigation as a map', function() { + it("should correctly parse navigation as a map", function() { book.should.have.property("navigation"); book.navigation.should.have.property("README.md"); book.navigation.should.have.property("README.md"); }); - it('should correctly include filenames', function() { + it("should correctly include filenames", function() { book.navigation.should.have.property("README.md"); book.navigation.should.have.property("PAGE1.md"); book.navigation.should.have.property("folder/PAGE2.md"); book.navigation.should.not.have.property("NOTFOUND.md"); }); - it('should correctly detect next/prev for README', function() { - var README = book.navigation['README.md']; + it("should correctly detect next/prev for README", function() { + var README = book.navigation["README.md"]; README.index.should.equal(0); - README.should.have.property('next'); + README.should.have.property("next"); should(README.prev).not.be.ok(); - README.next.should.have.property('path'); - README.next.path.should.equal('PAGE1.md'); + README.next.should.have.property("path"); + README.next.path.should.equal("PAGE1.md"); }); - it('should correctly detect next/prev a page', function() { - var PAGE = book.navigation['PAGE1.md']; + it("should correctly detect next/prev a page", function() { + var PAGE = book.navigation["PAGE1.md"]; PAGE.index.should.equal(1); - PAGE.should.have.property('next'); - PAGE.should.have.property('prev'); + PAGE.should.have.property("next"); + PAGE.should.have.property("prev"); - PAGE.prev.should.have.property('path'); - PAGE.prev.path.should.equal('README.md'); + PAGE.prev.should.have.property("path"); + PAGE.prev.path.should.equal("README.md"); - PAGE.next.should.have.property('path'); - PAGE.next.path.should.equal('folder/PAGE2.md'); + PAGE.next.should.have.property("path"); + PAGE.next.path.should.equal("folder/PAGE2.md"); }); - it('should correctly detect next/prev for last page', function() { - var PAGE = book.navigation['folder/PAGE2.md']; + it("should correctly detect next/prev for last page", function() { + var PAGE = book.navigation["folder/PAGE2.md"]; PAGE.index.should.equal(2); - PAGE.should.have.property('prev'); + PAGE.should.have.property("prev"); should(PAGE.next).not.be.ok(); - PAGE.prev.should.have.property('path'); - PAGE.prev.path.should.equal('PAGE1.md'); + PAGE.prev.should.have.property("path"); + PAGE.prev.path.should.equal("PAGE1.md"); }); }); diff --git a/test/plugins/replace_highlight/index.js b/test/plugins/replace_highlight/index.js index 25f9642..2e8f71d 100644 --- a/test/plugins/replace_highlight/index.js +++ b/test/plugins/replace_highlight/index.js @@ -2,7 +2,7 @@ module.exports = { blocks: { "code": { process: function(blk) { - var lang = blk.kwargs.language || 'code'; + var lang = blk.kwargs.language || "code"; return lang+"_"+blk.body+"_"+lang; } diff --git a/test/resolve.js b/test/resolve.js index b31a10d..e474ed0 100644 --- a/test/resolve.js +++ b/test/resolve.js @@ -1,7 +1,6 @@ -var fs = require('fs'); -var path = require('path'); +var path = require("path"); -describe('Resolve Files', function () { +describe("Resolve Files", function () { var book; before(function() { @@ -11,50 +10,50 @@ describe('Resolve Files', function () { }); }); - describe('book.fileIsInBook', function() { - it('should return true for correct paths', function() { - book.fileIsInBook(path.join(book.root, 'README.md')).should.equal(true); - book.fileIsInBook(path.join(book.root, 'styles/website.css')).should.equal(true); + describe("book.fileIsInBook", function() { + it("should return true for correct paths", function() { + book.fileIsInBook(path.join(book.root, "README.md")).should.equal(true); + book.fileIsInBook(path.join(book.root, "styles/website.css")).should.equal(true); }); - it('should return true for root folder', function() { - book.fileIsInBook(path.join(book.root, './')).should.equal(true); + it("should return true for root folder", function() { + book.fileIsInBook(path.join(book.root, "./")).should.equal(true); book.fileIsInBook(book.root).should.equal(true); }); - it('should return false for files out of scope', function() { - book.fileIsInBook(path.join(book.root, '../')).should.equal(false); - book.fileIsInBook('README.md').should.equal(false); - book.fileIsInBook(path.resolve(book.root, '../README.md')).should.equal(false); + it("should return false for files out of scope", function() { + book.fileIsInBook(path.join(book.root, "../")).should.equal(false); + book.fileIsInBook("README.md").should.equal(false); + book.fileIsInBook(path.resolve(book.root, "../README.md")).should.equal(false); }); - it('should correctly handle windows paths', function() { - book.fileIsInBook(path.join(book.root, '\\styles\\website.css')).should.equal(true); + it("should correctly handle windows paths", function() { + book.fileIsInBook(path.join(book.root, "\\styles\\website.css")).should.equal(true); }); }); - describe('book.resolve', function() { - it('should resolve a file to its absolute path', function() { - book.resolve('README.md').should.equal(path.resolve(book.root, 'README.md')); - book.resolve('website/README.md').should.equal(path.resolve(book.root, 'website/README.md')); + describe("book.resolve", function() { + it("should resolve a file to its absolute path", function() { + book.resolve("README.md").should.equal(path.resolve(book.root, "README.md")); + book.resolve("website/README.md").should.equal(path.resolve(book.root, "website/README.md")); }); - it('should correctly handle windows paths', function() { - book.resolve('styles\\website.css').should.equal(path.resolve(book.root, 'styles\\website.css')); + it("should correctly handle windows paths", function() { + book.resolve("styles\\website.css").should.equal(path.resolve(book.root, "styles\\website.css")); }); - it('should correctly resolve all arguments', function() { - book.resolve('test', 'hello', '..', 'README.md').should.equal(path.resolve(book.root, 'test/README.md')); + it("should correctly resolve all arguments", function() { + book.resolve("test", "hello", "..", "README.md").should.equal(path.resolve(book.root, "test/README.md")); }); - it('should correctly resolve to root folder', function() { - book.resolve('test', '/README.md').should.equal(path.resolve(book.root, 'README.md')); - book.resolve('test', '\\README.md').should.equal(path.resolve(book.root, 'README.md')); + it("should correctly resolve to root folder", function() { + book.resolve("test", "/README.md").should.equal(path.resolve(book.root, "README.md")); + book.resolve("test", "\\README.md").should.equal(path.resolve(book.root, "README.md")); }); - it('should throw an error for file out of book', function() { + it("should throw an error for file out of book", function() { (function() { - return book.resolve('../README.md'); + return book.resolve("../README.md"); }).should.throw(); }); }); diff --git a/test/summary.js b/test/summary.js index 9c6df00..2d3a248 100644 --- a/test/summary.js +++ b/test/summary.js @@ -1,8 +1,8 @@ -var fs = require('fs'); -var path = require('path'); +var fs = require("fs"); +var path = require("path"); -describe('Summary', function () { - describe('Parsing', function() { +describe("Summary", function () { + describe("Parsing", function() { var book; before(function() { @@ -12,13 +12,13 @@ describe('Summary', function () { }); }); - it('should correctly list items', function() { + it("should correctly list items", function() { book.should.have.property("summary"); book.summary.should.have.property("chapters"); book.summary.chapters.should.have.lengthOf(4); }); - it('should correctly mark non-existant entries', function() { + it("should correctly mark non-existant entries", function() { book.summary.chapters[0].exists.should.have.equal(true); book.summary.chapters[1].exists.should.have.equal(true); book.summary.chapters[2].exists.should.have.equal(true); @@ -26,7 +26,7 @@ describe('Summary', function () { }); }); - describe('Generation', function() { + describe("Generation", function() { var book; before(function() { @@ -36,30 +36,30 @@ describe('Summary', function () { }); }); - it('should create files according to summary', function() { + it("should create files according to summary", function() { book.should.have.file("index.html"); book.should.have.file("PAGE1.html"); book.should.have.file("folder/PAGE2.html"); }); - it('should correctly output summary', function() { + it("should correctly output summary", function() { var PAGE = fs.readFileSync( path.join(book.options.output, "index.html"), { encoding: "utf-8" } ); PAGE.should.be.html({ - ".book-summary .chapter[data-level='0'] a": { + ".book-summary .chapter[data-level=\"0\"] a": { attributes: { href: "./index.html" } }, - ".book-summary .chapter[data-level='1'] a": { + ".book-summary .chapter[data-level=\"1\"] a": { attributes: { href: "./PAGE1.html" } }, - ".book-summary .chapter[data-level='2'] a": { + ".book-summary .chapter[data-level=\"2\"] a": { attributes: { href: "./folder/PAGE2.html" } diff --git a/test/templating.js b/test/templating.js index af29d25..f92154b 100644 --- a/test/templating.js +++ b/test/templating.js @@ -1,6 +1,6 @@ var pkg = require("../package.json"); -describe('Templating', function () { +describe("Templating", function () { var book; before(function() { @@ -12,19 +12,19 @@ describe('Templating', function () { var testTpl = function(str, args, options) { return book.template.renderString(str, args, options) - .then(book.template.postProcess) + .then(book.template.postProcess); }; - describe('Context', function() { - it('should correctly have access to generator', function() { - return testTpl('{{ gitbook.generator }}') + describe("Context", function() { + it("should correctly have access to generator", function() { + return testTpl("{{ gitbook.generator }}") .then(function(content) { content.should.equal("website"); }); }); - it('should correctly have access to gitbook version', function() { - return testTpl('{{ gitbook.version }}') + it("should correctly have access to gitbook version", function() { + return testTpl("{{ gitbook.version }}") .then(function(content) { content.should.equal(pkg.version.toString()); }); diff --git a/test/website.js b/test/website.js index 91340a0..ebbd18c 100644 --- a/test/website.js +++ b/test/website.js @@ -1,8 +1,5 @@ -var fs = require('fs'); -var path = require('path'); - -describe('Website generator', function () { - describe('Basic Book', function() { +describe("Website generator", function () { + describe("Basic Book", function() { var book; before(function() { @@ -12,11 +9,11 @@ describe('Website generator', function () { }); }); - it('should correctly output an index.html', function() { + it("should correctly output an index.html", function() { book.should.have.file("index.html"); }); - it('should correctly copy assets', function() { + it("should correctly copy assets", function() { book.should.have.file("gitbook"); book.should.have.file("gitbook/app.js"); book.should.have.file("gitbook/style.css"); |