Skip to content

Commit 391ec4f

Browse files
yuichi10tkyi
authored andcommitted
feat(1082): Add getBranchList function (#10)
1 parent 93d4b01 commit 391ec4f

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,17 @@ class ScmRouter extends Scm {
357357
getDisplayName(config) {
358358
return this.scms[config.scmContext].getDisplayName();
359359
}
360+
361+
/**
362+
* Get branch info of scmContext
363+
* @method _getBranchList
364+
* @param {Object} config Configuration
365+
* @param {String} config.scmContext Name of scm context
366+
* @return {String} branch info of scmContext
367+
*/
368+
_getBranchList(config) {
369+
return this.chooseScm(config).then(scm => scm.getBranchList(config));
370+
}
360371
}
361372

362373
module.exports = ScmRouter;

test/index.test.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ describe('index test', () => {
4949
'getFile',
5050
'getChangedFiles',
5151
'getOpenedPRs',
52-
'getPrInfo'
52+
'getPrInfo',
53+
'getBranchList'
5354
].forEach((method) => {
5455
mock[method] = sinon.stub().resolves(plugin);
5556
});
@@ -900,4 +901,23 @@ describe('index test', () => {
900901
assert.calledOnce(exampleScm.getDisplayName);
901902
});
902903
});
904+
905+
describe('_getBranchList', () => {
906+
const config = { scmContext: 'example.context' };
907+
908+
it('call origin getBranchList', () => {
909+
const scmGithub = scm.scms['github.context'];
910+
const exampleScm = scm.scms['example.context'];
911+
const scmGitlab = scm.scms['gitlab.context'];
912+
913+
return scm._getBranchList(config)
914+
.then((result) => {
915+
assert.strictEqual(result, 'example');
916+
assert.notCalled(scmGithub.getBranchList);
917+
assert.notCalled(scmGitlab.getBranchList);
918+
assert.calledOnce(exampleScm.getBranchList);
919+
assert.calledWith(exampleScm.getBranchList, config);
920+
});
921+
});
922+
});
903923
});

0 commit comments

Comments
 (0)