summaryrefslogtreecommitdiffstats
path: root/test/links.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/links.js')
-rw-r--r--test/links.js39
1 files changed, 18 insertions, 21 deletions
diff --git a/test/links.js b/test/links.js
index 2c68a23..5c7823d 100644
--- a/test/links.js
+++ b/test/links.js
@@ -1,40 +1,37 @@
-var path = require('path');
-var _ = require('lodash');
-var assert = require('assert');
-
+var should = require('should');
var links = require("../lib/utils/links");
describe('Links', function () {
it('should correctly test external links', function() {
- assert(links.isExternal("http://google.fr"));
- assert(links.isExternal("https://google.fr"));
- assert(!links.isExternal("test.md"));
- assert(!links.isExternal("folder/test.md"));
- assert(!links.isExternal("/folder/test.md"));
+ 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);
+ links.isExternal("folder/test.md").should.be.exactly(false);
+ links.isExternal("/folder/test.md").should.be.exactly(false);
});
- it('should correctly test anchor links', function() {
- assert(links.isAnchor("#test"));
- assert(links.isAnchor(" #test"));
- assert(!links.isAnchor("https://google.fr#test"));
- assert(!links.isAnchor("test.md#test"));
+ 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() {
- assert.equal(links.toAbsolute("http://google.fr"), "http://google.fr");
- assert.equal(links.toAbsolute("test.md", "./", "./"), "test.md");
- assert.equal(links.toAbsolute("folder/test.md", "./", "./"), "folder/test.md");
+ 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() {
- assert.equal(links.toAbsolute("folder\\test.md", "./", "./"), "folder/test.md");
+ links.toAbsolute("folder\\test.md", "./", "./").should.be.equal("folder/test.md");
});
it('should correctly handle absolute path', function() {
- assert.equal(links.toAbsolute("/test.md", "./", "./"), "test.md");
- assert.equal(links.toAbsolute("/test.md", "test", "test"), "../test.md");
- assert.equal(links.toAbsolute("/sub/test.md", "test", "test"), "../sub/test.md");
+ 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");
});
});
});