Skip to content

Commit

Permalink
add index test
Browse files Browse the repository at this point in the history
  • Loading branch information
justindhillon committed Apr 24, 2024
1 parent 6de7cde commit 73a2136
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/index.test.ts
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;
});
Binary file added tests/test-folder/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions tests/test-folder/test.txt
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

0 comments on commit 73a2136

Please sign in to comment.