-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from justindhillon/test
Write new tests
- Loading branch information
Showing
18 changed files
with
3,342 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { checkLink } from "../checkLink"; | ||
|
||
test('api. returns false', async () => { | ||
expect(await checkLink("https://api.pythagora.io/telemetry")).toBe(false); | ||
}); | ||
|
||
test('localhost returns false', async () => { | ||
expect(await checkLink("https://localhost/")).toBe(false); | ||
expect(await checkLink("https://127.0.0.1/")).toBe(false); | ||
}); | ||
|
||
test('White Listed URLS return false', async () => { | ||
expect(await checkLink("https://www.google.com/")).toBe(false); | ||
expect(await checkLink("https://example.com/")).toBe(false); | ||
expect(await checkLink("https://www.example.com/")).toBe(false); | ||
expect(await checkLink("https://example.org/")).toBe(false); | ||
expect(await checkLink("https://www.example.org/")).toBe(false); | ||
expect(await checkLink("https://goo.gl/")).toBe(false); | ||
expect(await checkLink("https://fonts.googleapis.com")).toBe(false); | ||
expect(await checkLink("https://fonts.gstatic.com")).toBe(false); | ||
}); | ||
|
||
test('Valid Links return false', async () => { | ||
expect(await checkLink("https://www.google.com/")).toBe(false); | ||
expect(await checkLink("https://www.wikipedia.org/")).toBe(false); | ||
expect(await checkLink("https://www.nasa.gov/")).toBe(false); | ||
expect(await checkLink("https://www.bbc.com/")).toBe(false); | ||
expect(await checkLink("https://www.un.org/")).toBe(false); | ||
}); | ||
|
||
test('Broken Links return true', async () => { | ||
expect(await checkLink("https://www.google.com/page-not-found")).toBe(true); | ||
expect(await checkLink("https://www.wikipedia.org/page-not-found")).toBe(true); | ||
expect(await checkLink("https://www.nasa.gov/page-not-found")).toBe(true); | ||
expect(await checkLink("https://www.bbc.com/page-not-found")).toBe(true); | ||
expect(await checkLink("https://www.un.org/page-not-found")).toBe(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import linkInspector from "../index"; | ||
|
||
test('Broken link calls callback', async () => { | ||
const promise1 = new Promise<void>((resolve) => { | ||
const callback = (link: string) => { | ||
expect(link).toBe('https://www.google.com/page-not-found'); | ||
resolve(); | ||
}; | ||
|
||
linkInspector("https://www.google.com/page-not-found", callback); | ||
}); | ||
|
||
const promise2 = new Promise<void>((resolve) => { | ||
const callback = (link: string) => { | ||
expect(link).toBe('https://www.wikipedia.org/page-not-found'); | ||
resolve(); | ||
}; | ||
|
||
linkInspector("https://www.wikipedia.org/page-not-found", callback); | ||
}); | ||
|
||
await promise1; | ||
await promise2; | ||
}); | ||
|
||
test('Test on real folder', async () => { | ||
const promise = new Promise<void>((resolve) => { | ||
const callback = (link: string) => { | ||
expect(link).toBe('https://www.wikipedia.org/page-not-found'); | ||
resolve(); | ||
}; | ||
|
||
linkInspector("tests/test-folder", callback); | ||
}); | ||
|
||
await promise; | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
bowishadve https://www.google.com/ tribution pendaytive | ||
astrus digikiki quz trudicats alginall shopolized | ||
beatorlds reflupper https://www.wikipedia.org/page-not-found | ||
nucch sa eadicerolawyne antilds ij nessinfulleter | ||
expercity larv posion vikins revotempution norted | ||
https://www.un.org/ sweeds corehooker iwoppion burgination |
This file was deleted.
Oops, something went wrong.