From 9a0e5e2b34125bcdb18a11e8276fe0d701f38c1d Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 10 Jun 2020 20:19:36 +0200 Subject: [PATCH] Add test to demonstrate issue #12 Origin-relative URLs are parsed as relative to the directory they're in. --- .../dir-a/source.html | 3 +++ .../dir-b/target.html | 3 +++ test/test.js | 21 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 test/fixture-root-relative-url/dir-a/source.html create mode 100644 test/fixture-root-relative-url/dir-b/target.html diff --git a/test/fixture-root-relative-url/dir-a/source.html b/test/fixture-root-relative-url/dir-a/source.html new file mode 100644 index 0000000..22049d8 --- /dev/null +++ b/test/fixture-root-relative-url/dir-a/source.html @@ -0,0 +1,3 @@ + + dir-b/target + diff --git a/test/fixture-root-relative-url/dir-b/target.html b/test/fixture-root-relative-url/dir-b/target.html new file mode 100644 index 0000000..0ab06af --- /dev/null +++ b/test/fixture-root-relative-url/dir-b/target.html @@ -0,0 +1,3 @@ + + This page is the target of a link in ../dir-a/source.html. + \ No newline at end of file diff --git a/test/test.js b/test/test.js index 53c8055..ba87d3e 100644 --- a/test/test.js +++ b/test/test.js @@ -48,6 +48,27 @@ describe('link checker', () => { }) }) + it('run link checker with root-relative-url fixtures', () => { + return checker(dir('root-relative-url'), {['warn-name-attr']: true}).then(result => { + const expectedErrors = [] + const expectedWarnings = [] + + expect(result.stats.errors).eql(expectedErrors) + expect(result.stats.warnings).eql(expectedWarnings) + expect(result.stats).eql({ + parsedFiles: 2, + localLinks: 1, + localAnchorLinks: 0, + remoteLinks: 0, + remoteAnchorLinks: 0, + parentLinks: 0, + parentAnchorLinks: 0, + errors: expectedErrors, + warnings: expectedWarnings + }) + }) + }) + it('run link checker with scaladoc fixtures', () => { return checker(dir('scaladoc'), {javadoc: true}).then(result => { const expectedErrors = [ { type: 'page',