@@ -244,6 +244,47 @@ describe('modules/platform/gerrit/index', () => {
244244 TAG_PULL_REQUEST_BODY ,
245245 ) ;
246246 } ) ;
247+
248+ it ( 'updatePr() - with addLabels => add hashtags' , async ( ) => {
249+ const change = partial < GerritChange > ( { } ) ;
250+ clientMock . getChange . mockResolvedValueOnce ( change ) ;
251+ await gerrit . updatePr ( {
252+ number : 123456 ,
253+ prTitle : change . subject ,
254+ addLabels : [ 'label1' , 'label2' ] ,
255+ } ) ;
256+ expect ( clientMock . setHashtags ) . toHaveBeenCalledExactlyOnceWith ( 123456 , {
257+ add : [ 'label1' , 'label2' ] ,
258+ } ) ;
259+ } ) ;
260+
261+ it ( 'updatePr() - with removeLabels => remove hashtags' , async ( ) => {
262+ const change = partial < GerritChange > ( { } ) ;
263+ clientMock . getChange . mockResolvedValueOnce ( change ) ;
264+ await gerrit . updatePr ( {
265+ number : 123456 ,
266+ prTitle : change . subject ,
267+ removeLabels : [ 'old-label' ] ,
268+ } ) ;
269+ expect ( clientMock . setHashtags ) . toHaveBeenCalledExactlyOnceWith ( 123456 , {
270+ remove : [ 'old-label' ] ,
271+ } ) ;
272+ } ) ;
273+
274+ it ( 'updatePr() - with addLabels and removeLabels => update hashtags in single call' , async ( ) => {
275+ const change = partial < GerritChange > ( { } ) ;
276+ clientMock . getChange . mockResolvedValueOnce ( change ) ;
277+ await gerrit . updatePr ( {
278+ number : 123456 ,
279+ prTitle : change . subject ,
280+ addLabels : [ 'new-label' ] ,
281+ removeLabels : [ 'old-label' ] ,
282+ } ) ;
283+ expect ( clientMock . setHashtags ) . toHaveBeenCalledExactlyOnceWith ( 123456 , {
284+ add : [ 'new-label' ] ,
285+ remove : [ 'old-label' ] ,
286+ } ) ;
287+ } ) ;
247288 } ) ;
248289
249290 describe ( 'createPr()' , ( ) => {
@@ -780,11 +821,10 @@ describe('modules/platform/gerrit/index', () => {
780821 it ( 'deleteLabel() - deletes a label' , async ( ) => {
781822 const pro = gerrit . deleteLabel ( 123456 , 'hashtag1' ) ;
782823 await expect ( pro ) . resolves . toBeUndefined ( ) ;
783- expect ( clientMock . deleteHashtag ) . toHaveBeenCalledTimes ( 1 ) ;
784- expect ( clientMock . deleteHashtag ) . toHaveBeenCalledExactlyOnceWith (
785- 123456 ,
786- 'hashtag1' ,
787- ) ;
824+ expect ( clientMock . setHashtags ) . toHaveBeenCalledTimes ( 1 ) ;
825+ expect ( clientMock . setHashtags ) . toHaveBeenCalledExactlyOnceWith ( 123456 , {
826+ remove : [ 'hashtag1' ] ,
827+ } ) ;
788828 } ) ;
789829 } ) ;
790830
0 commit comments