gr-confirm-move-dialog: Fix _getProjectBranchesSuggestions
Currently fataling because in construct we call
_getProjectBranchesSuggestions without params and
thus is undefined/false.
We remove the check as it is not needed.
Change-Id: I8d4ead0bf3a8c30d0ecefdc190e4ba4ea7ede29d
(cherry picked from commit 7db9fdcdd7e78140fee2ee3b662d94bddcbbe6a9)
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts
index e9cf19e..7150ddf 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts
@@ -65,7 +65,7 @@
project?: RepoName;
@property({type: Object})
- _query?: (_text?: string) => Promise<AutocompleteSuggestion[]>;
+ _query: (input: string) => Promise<AutocompleteSuggestion[]>;
get keyBindings() {
return {
@@ -75,7 +75,7 @@
constructor() {
super();
- this._query = () => this._getProjectBranchesSuggestions();
+ this._query = (text: string) => this._getProjectBranchesSuggestions(text);
}
_handleConfirmTap(e: Event) {
@@ -101,10 +101,9 @@
}
_getProjectBranchesSuggestions(
- input?: string
+ input: string
): Promise<AutocompleteSuggestion[]> {
if (!this.project) return Promise.reject(new Error('Missing project'));
- if (!input) return Promise.reject(new Error('Missing input'));
if (input.startsWith('refs/heads/')) {
input = input.substring('refs/heads/'.length);
}
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.js b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.js
index 43bde75..d51388e 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.js
@@ -65,5 +65,12 @@
done();
});
});
+
+ test('_getProjectBranchesSuggestions input empty string', done => {
+ element._getProjectBranchesSuggestions('').then(branches => {
+ assert.equal(branches.length, 0);
+ done();
+ });
+ });
});