Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edugfilho committed Nov 14, 2024
1 parent 3df6ef7 commit 131b60c
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions tests/formatters.codesearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ import { getCodeSearchLink } from "../src/formatters/codesearch";

describe("Searchfox links for firefox-desktop", () => {
it("works as expected", () => {
expect(getCodeSearchLink("firefox_desktop", "test.metric_name")).toBe(
expect(
getCodeSearchLink("test.metric_name", "firefox_desktop", {
source_url: "https://foo.bar",
})
).toBe(
"https://searchfox.org/mozilla-central/search?q=test.metric_name|test.metricName|Test.metricName|test.metric_name|test::metric_name&regexp=true"
);
expect(
getCodeSearchLink("firefox_desktop", "test_category.test_name")
getCodeSearchLink("test_category.test_name", "firefox_desktop", {
source_url: "https://foo.bar",
})
).toBe(
"https://searchfox.org/mozilla-central/search?q=test_category.test_name|testCategory.testName|TestCategory.testName|test_category.test_name|test_category::test_name&regexp=true"
);
Expand All @@ -15,25 +21,55 @@ describe("Searchfox links for firefox-desktop", () => {

describe("Searchfox links for applications in mozilla-mobile", () => {
it("works as expected", () => {
expect(getCodeSearchLink("fenix", "test.metric_name")).toBe(
expect(
getCodeSearchLink("test.metric_name", "fenix", {
source_url: "https://foo.bar",
})
).toBe(
"https://searchfox.org/mozilla-mobile/search?q=test.metric_name|test.metricName|Test.metricName|test.metric_name|test::metric_name&path=fenix&regexp=true"
);
expect(getCodeSearchLink("fenix", "test_category.test_name")).toBe(
expect(
getCodeSearchLink("test_category.test_name", "fenix", {
source_url: "https://foo.bar",
})
).toBe(
"https://searchfox.org/mozilla-mobile/search?q=test_category.test_name|testCategory.testName|TestCategory.testName|test_category.test_name|test_category::test_name&path=fenix&regexp=true"
);
expect(
getCodeSearchLink("test_category.test_name", "fenix", {
source_url:
"https://github.com/mozilla/application-services/foo/bar/metrics.yaml",
})
).toBe(
"https://searchfox.org/mozilla-mobile/search?q=test_category.test_name|testCategory.testName|TestCategory.testName|test_category.test_name|test_category::test_name&path=application-services&regexp=true"
);
expect(
getCodeSearchLink("test_category.test_name", "firefox_ios", {
source_url:
"https://github.com/mozilla/application-services/foo/bar/metrics.yaml",
})
).toBe(
"https://searchfox.org/mozilla-mobile/search?q=test_category.test_name|testCategory.testName|TestCategory.testName|test_category.test_name|test_category::test_name&path=application-services&regexp=true"
);
});
});

describe("returns Sourcegraph link if the application is not indexed on Searchfox", () => {
it("works as expected", () => {
expect(getCodeSearchLink("mozregression", "usage.bad_date")).toBe(
expect(
getCodeSearchLink("usage.bad_date", "mozregression", {
source_url: "https://foo.bar",
})
).toBe(
"https://sourcegraph.com/search?q=repo:%5Egithub%5C.com%5C/%5BMm%5Dozilla%28.*%29%5C/mozregression%24+usage.bad_date|usage.badDate|Usage.badDate|usage.bad_date|usage::bad_date&patternType=regexp"
);
});
});

describe("returns undefined if the application cannot be indexed", () => {
it("works as expected", () => {
expect(getCodeSearchLink("foo", "test.metric")).toBeUndefined();
expect(
getCodeSearchLink("test.metric", "foo", { source_url: "https://foo.bar" })
).toBeUndefined();
});
});

0 comments on commit 131b60c

Please sign in to comment.