From 5900cb997aad0b7833510b2b20a8595d22cf0423 Mon Sep 17 00:00:00 2001 From: Tobias Jacksteit Date: Wed, 3 Jun 2020 15:01:38 +0800 Subject: [PATCH] added unit tests --- test/utils/urlMatcher.test.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/test/utils/urlMatcher.test.js b/test/utils/urlMatcher.test.js index 5b84686..42ae1dd 100644 --- a/test/utils/urlMatcher.test.js +++ b/test/utils/urlMatcher.test.js @@ -6,7 +6,7 @@ describe("utils", () => { let matcher beforeEach(() => { - matcher = createMatcher(remoteServices) + matcher = createMatcher(remoteServices, {}) }) describe("createMatcher", () => { @@ -162,4 +162,27 @@ describe("utils", () => { }) }) }) + + describe("urlMatcher with overrideHosts", () => { + let matcher + + beforeEach(() => { + matcher = createMatcher(remoteServices, { + github: "https://my-custom-github-url.com", + }) + }) + + describe("createMatcher", () => { + it("matches overridden host and path", () => { + const service = matcher("https://my-custom-github-url.com/hundertzehn/mocoapp/pull/123") + expect(service.key).toEqual("github-pr") + expect(service.name).toEqual("github") + }) + + it("doesn't match default host and path", () => { + const service = matcher("https://github.com/hundertzehn/mocoapp/pull/123") + expect(service).toBe(undefined) + }) + }) + }) })