From 519ab1aecb6607659c0335f79db3e1df3ffbc7c8 Mon Sep 17 00:00:00 2001 From: Eric Ciarla Date: Sat, 15 Jun 2024 17:14:09 -0400 Subject: [PATCH] Update unit tests --- .../api/src/__tests__/e2e_withAuth/index.test.ts | 2 +- .../scraper/WebScraper/__tests__/crawler.test.ts | 6 +++--- .../utils/__tests__/maxDepthUtils.test.ts | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/apps/api/src/__tests__/e2e_withAuth/index.test.ts b/apps/api/src/__tests__/e2e_withAuth/index.test.ts index 3b27cbf..9f04093 100644 --- a/apps/api/src/__tests__/e2e_withAuth/index.test.ts +++ b/apps/api/src/__tests__/e2e_withAuth/index.test.ts @@ -655,7 +655,7 @@ describe("E2E Tests for API Routes", () => { const testurls = completedResponse.body.data.map( (item: any) => item.metadata?.sourceURL ); - console.log(testurls) + //console.log(testurls) expect(completedResponse.statusCode).toBe(200); expect(completedResponse.body).toHaveProperty("status"); diff --git a/apps/api/src/scraper/WebScraper/__tests__/crawler.test.ts b/apps/api/src/scraper/WebScraper/__tests__/crawler.test.ts index 6f7b632..c7c54aa 100644 --- a/apps/api/src/scraper/WebScraper/__tests__/crawler.test.ts +++ b/apps/api/src/scraper/WebScraper/__tests__/crawler.test.ts @@ -73,7 +73,7 @@ describe('WebCrawler maxDepth and filterLinks', () => { const initialUrl = 'http://example.com'; // Set initial URL for this test const enteredMaxCrawledDepth = 0; maxCrawledDepth = getAdjustedMaxDepth(initialUrl, enteredMaxCrawledDepth); - console.log(maxCrawledDepth); + crawler = new WebCrawler({ initialUrl: initialUrl, @@ -101,7 +101,7 @@ describe('WebCrawler maxDepth and filterLinks', () => { const initialUrl = 'http://example.com/page1'; // Set initial URL for this test const enteredMaxCrawledDepth = 1; maxCrawledDepth = getAdjustedMaxDepth(initialUrl, enteredMaxCrawledDepth); - console.log(maxCrawledDepth); + crawler = new WebCrawler({ initialUrl: initialUrl, @@ -130,7 +130,7 @@ describe('WebCrawler maxDepth and filterLinks', () => { const initialUrl = 'http://example.com/page1'; // Set initial URL for this test const enteredMaxCrawledDepth = 2; maxCrawledDepth = getAdjustedMaxDepth(initialUrl, enteredMaxCrawledDepth); - console.log(maxCrawledDepth); + crawler = new WebCrawler({ initialUrl: initialUrl, diff --git a/apps/api/src/scraper/WebScraper/utils/__tests__/maxDepthUtils.test.ts b/apps/api/src/scraper/WebScraper/utils/__tests__/maxDepthUtils.test.ts index e77242c..863a689 100644 --- a/apps/api/src/scraper/WebScraper/utils/__tests__/maxDepthUtils.test.ts +++ b/apps/api/src/scraper/WebScraper/utils/__tests__/maxDepthUtils.test.ts @@ -22,15 +22,25 @@ describe('Testing getURLDepth and getAdjustedMaxDepth', () => { }); - it('Adjusted maxDepth should return 1 for scrapethissite.com', () => { + it('Adjusted maxDepth should return 1 for scrapethissite.com and max depth param of 1', () => { const enteredURL = "https://scrapethissite.com" expect(getAdjustedMaxDepth(enteredURL, 1)).toBe(1); }); + it('Adjusted maxDepth should return 0 for scrapethissite.com and max depth param of 0', () => { + const enteredURL = "https://scrapethissite.com" + expect(getAdjustedMaxDepth(enteredURL, 0)).toBe(0); - it('Adjusted maxDepth should return 5 for scrapethissite.com/pages/articles', () => { + }); + + it('Adjusted maxDepth should return 0 for mendable.ai and max depth param of 0', () => { + const enteredURL = "https://mendable.ai" + expect(getAdjustedMaxDepth(enteredURL, 0)).toBe(0); + }); + + it('Adjusted maxDepth should return 4 for scrapethissite.com/pages/articles and max depth param of 2', () => { const enteredURL = "https://scrapethissite.com/pages/articles" - expect(getAdjustedMaxDepth(enteredURL, 2)).toBe(5); + expect(getAdjustedMaxDepth(enteredURL, 2)).toBe(4); });