diff options
Diffstat (limited to 'polygerrit-ui/app/services/gr-rest-api/gr-rest-api-impl_test.js')
-rw-r--r-- | polygerrit-ui/app/services/gr-rest-api/gr-rest-api-impl_test.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/polygerrit-ui/app/services/gr-rest-api/gr-rest-api-impl_test.js b/polygerrit-ui/app/services/gr-rest-api/gr-rest-api-impl_test.js index d8c3ff274f..b4defb50c0 100644 --- a/polygerrit-ui/app/services/gr-rest-api/gr-rest-api-impl_test.js +++ b/polygerrit-ui/app/services/gr-rest-api/gr-rest-api-impl_test.js @@ -459,6 +459,31 @@ suite('gr-rest-api-service-impl tests', () => { assert.deepEqual(sendStub.lastCall.args[0].body, {token: 'foo'}); }); + test('setPreferredAccountEmail', () => { + const email1 = 'email1@example.com'; + const email2 = 'email2@example.com'; + const encodedEmail = encodeURIComponent(email2); + const sendStub = sinon.stub(element._restApiHelper, 'send').resolves(); + element._cache.set('/accounts/self/emails', [ + {email: email1, preferred: true}, + {email: email2, preferred: false}, + ]); + + return element.setPreferredAccountEmail(email2).then(() => { + assert.isTrue(sendStub.calledOnce); + assert.equal(sendStub.lastCall.args[0].method, 'PUT'); + assert.equal(sendStub.lastCall.args[0].url, + `/accounts/self/emails/${encodedEmail}/preferred` + ); + assert.deepEqual( + element._restApiHelper._cache.get('/accounts/self/emails'), [ + {email: email1, preferred: false}, + {email: email2, preferred: true}, + ] + ); + }); + }); + test('setAccountStatus', () => { const sendStub = sinon.stub(element._restApiHelper, 'send') .returns(Promise.resolve('OOO')); |