From d177c46471859405e34d5e1f475a1240693a77cf Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 30 Mar 2024 08:24:05 -0500 Subject: [PATCH] chore: Fix failing test --- .../__snapshots__/chrome-crawler.test.ts.snap | 26 ------------------- src/crawlers/__tests__/chrome-crawler.test.ts | 17 +++++++++++- src/crawlers/chrome-crawler.ts | 2 +- 3 files changed, 17 insertions(+), 28 deletions(-) delete mode 100644 src/crawlers/__tests__/__snapshots__/chrome-crawler.test.ts.snap diff --git a/src/crawlers/__tests__/__snapshots__/chrome-crawler.test.ts.snap b/src/crawlers/__tests__/__snapshots__/chrome-crawler.test.ts.snap deleted file mode 100644 index 18dd5a5..0000000 --- a/src/crawlers/__tests__/__snapshots__/chrome-crawler.test.ts.snap +++ /dev/null @@ -1,26 +0,0 @@ -// Bun Snapshot v1, https://goo.gl/fbAQLP - -exports[`Chrome Web Store Crawler should load and crawl an extension ID correctly 1`] = ` -{ - "iconUrl": "https://lh3.googleusercontent.com/GcffNyCJaxT2G9dsQCJHhUEMlu_E0vEzph5cLPrQj7UHKat7QyCzGu69Dmp_DDUL8rY-bPMFJceQarS1wcqdwTalTg=s256", - "id": "ocfdgncpifmegplaglcnglhioflaimkd", - "lastUpdated": "February 4, 2024", - "longDescription": -"Isn't it annoying when you open a small PR, but when you look at the diff, it's +2000 -16 because you installed a new library? Or what if you had to review that PR, don't line counts like that dissuade you from starting the review? -In reality, lots of code is generated nowadays and GitHub's line counts are not representative of a PR's true size. -This extension subtracts generated files from the total line counts, giving you a better idea of how big a PR really is. That's it. That's all it does. -Generated files are detected from the branch's root .gitattributes file. See GitHub's docs to learn how to mark a file as generated: https://docs.github.com/en/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github -For a simple example, checkout this extension's .gitattributes file! https://github.com/aklinker1/github-better-line-counts/blob/main/.gitattributes ---- -The extension is open source. Feel free to contribute if you have any ideas or just star it 😀 -https://github.com/aklinker1/github-better-line-counts" -, - "name": "GitHub: Better Line Counts", - "rating": 5, - "reviewCount": 2, - "shortDescription": "Remove generated files from GitHub line counts", - "storeUrl": "https://chromewebstore.google.com/detail/github-better-line-counts/ocfdgncpifmegplaglcnglhioflaimkd", - "version": "1.7.1", - "weeklyActiveUsers": 73, -} -`; diff --git a/src/crawlers/__tests__/chrome-crawler.test.ts b/src/crawlers/__tests__/chrome-crawler.test.ts index f38bf36..a840bab 100644 --- a/src/crawlers/__tests__/chrome-crawler.test.ts +++ b/src/crawlers/__tests__/chrome-crawler.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from "bun:test"; import { crawlExtension } from "../chrome-crawler"; +import { numberOfDFGCompiles } from "bun:jsc"; const githubBetterLineCountsId = "ocfdgncpifmegplaglcnglhioflaimkd"; @@ -7,6 +8,20 @@ describe("Chrome Web Store Crawler", () => { it("should load and crawl an extension ID correctly", async () => { const res = await crawlExtension(githubBetterLineCountsId, "en"); - expect(res).toMatchSnapshot(); + expect(res).toEqual({ + iconUrl: + "https://lh3.googleusercontent.com/GcffNyCJaxT2G9dsQCJHhUEMlu_E0vEzph5cLPrQj7UHKat7QyCzGu69Dmp_DDUL8rY-bPMFJceQarS1wcqdwTalTg=s256", + id: githubBetterLineCountsId, + lastUpdated: expect.any(String), + longDescription: expect.stringContaining("Isn't it annoying when you"), + name: "GitHub: Better Line Counts", + rating: expect.any(Number), + reviewCount: expect.any(Number), + shortDescription: "Remove generated files from GitHub line counts", + storeUrl: + "https://chromewebstore.google.com/detail/github-better-line-counts/ocfdgncpifmegplaglcnglhioflaimkd", + version: expect.any(String), + weeklyActiveUsers: expect.any(Number), + }); }); }); diff --git a/src/crawlers/chrome-crawler.ts b/src/crawlers/chrome-crawler.ts index 11f5731..5ba97e9 100644 --- a/src/crawlers/chrome-crawler.ts +++ b/src/crawlers/chrome-crawler.ts @@ -21,7 +21,7 @@ export async function crawlExtension( const { document } = parseHTML(html); // Uncomment to debug HTML - Bun.write("chrome.html", document.documentElement.outerHTML); + // Bun.write("chrome.html", document.documentElement.outerHTML); // Basic metadata const name = metaContent(document, "property=og:title");