Skip to content

Commit

Permalink
Merge pull request #23 from justindhillon/add-tests
Browse files Browse the repository at this point in the history
Add Tests
  • Loading branch information
justindhillon authored Nov 26, 2023
2 parents 03ba933 + 5439d5c commit 041d1e0
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/expected_output/brokenLinks
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
https://www.disney.com/notfound
https://www.drift.com/notfound/
https://www.helpscout.com/notfound/
https://coschedule.com/notfound
5 changes: 5 additions & 0 deletions test/expected_output/subfolder/brokenLinks
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://www.disney.com/notfound
https://www.drift.com/notfound/
https://www.helpscout.com/notfound/
https://coschedule.com/notfound
https://ubcevednts.com/notfound
18 changes: 18 additions & 0 deletions test/scanLinks.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const scanLinks = require("../bin/scan/scanLinks");

// Documentation on dircompare:
// https://gliviu.github.io/dc-api/index.html
const dircompare = require('dir-compare');
const options = { compareContent: true };

describe('scanLinks.js', () => {
test('scanLinks returns broken links', async () => {
await scanLinks("test/test_suite").then(async () => {
const res = dircompare.compareSync("test/expected_output", "output/test_suite", options);
console.log(res.same);
expect(res.same).toEqual(true);
}).catch(() => {
process.exit(1);
});
});
});
5 changes: 5 additions & 0 deletions test/test_suite/brokenLinks
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://www.disney.com/notfound
https://www.drift.com/notfound/
https://www.helpscout.com/notfound/
https://coschedule.com/notfound
https://ubcevednts.com/notfound
3 changes: 3 additions & 0 deletions test/test_suite/falsePositive
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://localhost:3000
http://localhost:8080/notfound
http://localhost:1234/path/not/found
5 changes: 5 additions & 0 deletions test/test_suite/subfolder/brokenLinks
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://www.disney.com/notfound
https://www.drift.com/notfound/
https://www.helpscout.com/notfound/
https://coschedule.com/notfound
https://ubcevednts.com/notfound
3 changes: 3 additions & 0 deletions test/test_suite/subfolder/falsePositive
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://localhost:3000
http://localhost:8080/notfound
http://localhost:1234/path/not/found
5 changes: 5 additions & 0 deletions test/test_suite/subfolder/workingLinks
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://www.disney.com
https://www.drift.com/
https://www.helpscout.com/
https://coschedule.com/
https://ubcevents.com/
5 changes: 5 additions & 0 deletions test/test_suite/workingLinks
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://www.disney.com
https://www.drift.com/
https://www.helpscout.com/
https://coschedule.com/
https://ubcevents.com/

0 comments on commit 041d1e0

Please sign in to comment.