integration-react: rename ScmAuth.mux to merge

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-08-29 19:31:34 +02:00
parent 72851acc4a
commit 827fdcae17
2 changed files with 8 additions and 4 deletions
@@ -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: {
@@ -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);
}