diff options
Diffstat (limited to 'test/links.js')
-rw-r--r-- | test/links.js | 30 |
1 files changed, 14 insertions, 16 deletions
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"); + }); }); }); |