Skip to content

Commit

Permalink
Merge pull request #693 from ikemo3/test/document_url
Browse files Browse the repository at this point in the history
test: add test for DocumentURL
  • Loading branch information
ikemo3 authored Apr 30, 2023
2 parents 5749e8a + 3c35389 commit f76a846
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/document_url.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import DocumentURL from "../apps/values/document_url";

const GOOGLE_SEARCH_URL =
"https://www.google.com/search?q=test&oq=test&aqs=chrome..69i57j0i131i433i512l2j0i512j0i433i512l4j0i512j0i433i512.505j0j7&sourceid=chrome&ie=UTF-8";
const GOOGLE_SEARCH_NEWS_TAB_URL =
"https://www.google.com/search?q=test&source=lnms&tbm=nws&sa=X&ved=2ahUKEwjJuafmmdH-AhWWdd4KHbaCCn4Q_AUoAXoECAEQAw&biw=1607&bih=806&dpr=2";
const GOOGLE_SEARCH_IMAGE_TAB_URL =
"https://www.google.com/search?q=test&tbm=isch&source=lnms&sa=X&ved=2ahUKEwi8uLDtmdH-AhXEEXAKHRn8ACQQ_AUoAnoECAEQBA&biw=1607&bih=806&dpr=2";

describe("DocumentURL", () => {
it("Google Search URL", () => {
const documentUrl = new DocumentURL(GOOGLE_SEARCH_URL);

expect(documentUrl.isGoogleSearch()).toBe(true);
expect(documentUrl.isGoogleSearchNewsTab()).toBe(false);
expect(documentUrl.isGoogleSearchImageTab()).toBe(false);
});

it("Google Search New Tab URL", () => {
const documentUrl = new DocumentURL(GOOGLE_SEARCH_NEWS_TAB_URL);

expect(documentUrl.isGoogleSearch()).toBe(false);
expect(documentUrl.isGoogleSearchNewsTab()).toBe(true);
expect(documentUrl.isGoogleSearchImageTab()).toBe(false);
});

it("Google Search Image Tab URL", () => {
const documentUrl = new DocumentURL(GOOGLE_SEARCH_IMAGE_TAB_URL);

expect(documentUrl.isGoogleSearch()).toBe(false);
expect(documentUrl.isGoogleSearchNewsTab()).toBe(false);
expect(documentUrl.isGoogleSearchImageTab()).toBe(true);
});
});

0 comments on commit f76a846

Please sign in to comment.