From 827fdcae17dd5e7bb99e1c3a7b47ce326c7c3ec4 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 29 Aug 2021 19:31:34 +0200 Subject: [PATCH] integration-react: rename ScmAuth.mux to merge Signed-off-by: Patrik Oldsberg --- packages/integration-react/src/api/ScmAuth.test.ts | 6 +++--- packages/integration-react/src/api/ScmAuth.ts | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/integration-react/src/api/ScmAuth.test.ts b/packages/integration-react/src/api/ScmAuth.test.ts index 519e98a475..966a2a0925 100644 --- a/packages/integration-react/src/api/ScmAuth.test.ts +++ b/packages/integration-react/src/api/ScmAuth.test.ts @@ -30,7 +30,7 @@ describe('ScmAuth', () => { const mockGithubAuth = new MockOAuthApi('github-access-token'); const mockGheAuth = new MockOAuthApi('ghe-access-token'); - const api = ScmAuth.mux( + const api = ScmAuth.merge( ScmAuth.forGithub(mockGithubAuth), ScmAuth.forGithub(mockGheAuth, { host: 'ghe.example.com', @@ -180,14 +180,14 @@ describe('ScmAuth', () => { }); it('should throw an error for unknown URLs', async () => { - const emptyMux = ScmAuth.mux(); + const emptyMux = ScmAuth.merge(); await expect( emptyMux.getCredentials({ url: 'http://example.com' }), ).rejects.toThrow( "No authentication provider available for access to 'http://example.com'", ); - const scmAuth = ScmAuth.mux( + const scmAuth = ScmAuth.merge( ScmAuth.forAuthApi(new MockOAuthApi('token'), { host: 'example.com', scopeMapping: { diff --git a/packages/integration-react/src/api/ScmAuth.ts b/packages/integration-react/src/api/ScmAuth.ts index 4aceeea712..77a82e8a4d 100644 --- a/packages/integration-react/src/api/ScmAuth.ts +++ b/packages/integration-react/src/api/ScmAuth.ts @@ -132,7 +132,11 @@ export class ScmAuth implements ScmAuthApi { }); } - static mux(...providers: ScmAuth[]): ScmAuthApi { + /** + * Merges together multiple ScmAuth instances into one that + * routes requests to the correct instance based on the URL. + */ + static merge(...providers: ScmAuth[]): ScmAuthApi { return new ScmAuthMux(providers); }