Skip to content

Commit

Permalink
fix: update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xinhyao committed Nov 15, 2024
1 parent c09d622 commit aa83ca5
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,26 @@ describe('plugin-authorization-browser-first-party', () => {
assert.calledOnce(webex.authorization.cancelQRCodePolling);
clock.restore();
});

it('should prevent concurrent polling attempts', async () => {
const clock = sinon.useFakeTimers();
const webex = makeWebex('http://example.com');
const options = {
device_code: 'test_code',
interval: 2,
expires_in: 300
};

webex.request.rejects({statusCode: 428, body: {message: 'authorization_pending'}});

// Start first polling request
webex.authorization.startQRCodePolling(options);
// Attempt second polling request
const secondPromise = webex.authorization.startQRCodePolling(options);

await assert.isRejected(secondPromise, /There is already a polling request/);
clock.restore();
});
});

describe('#cancelQRCodePolling()', () => {
Expand Down

0 comments on commit aa83ca5

Please sign in to comment.