Skip to content

Commit

Permalink
feat(cc-sdk): re-added-cc-code
Browse files Browse the repository at this point in the history
  • Loading branch information
adhmenon committed Nov 11, 2024
1 parent 994fe63 commit ff494fc
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions packages/@webex/plugin-cc/test/unit/spec/cc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,56 @@ describe('webex.cc', () => {
);
});
});

describe('stationLogout', () => {
it('should logout successfully', async () => {
const data = {logoutReason: 'Logout reason'};
const response = {};

const stationLogoutMock = jest
.spyOn(webex.cc.services.agent, 'logout')
.mockResolvedValue({} as StationLogoutResponse);

const result = await webex.cc.stationLogout(data);

expect(stationLogoutMock).toHaveBeenCalledWith({data: data});
expect(result).toEqual(response);
});

it('should handle error during stationLogout', async () => {
const data = {logoutReason: 'Logout reason'};
const error = new Error('Error while performing station logout');

jest.spyOn(webex.cc.services.agent, 'logout').mockRejectedValue(error);

await expect(webex.cc.stationLogout(data)).rejects.toThrow(error);

expect(webex.logger.error).toHaveBeenCalledWith(`file: cc: Station Logout failed: ${error}`);
});
});

describe('stationRelogin', () => {
it('should relogin successfully', async () => {
const response = {};

const stationLoginMock = jest
.spyOn(webex.cc.services.agent, 'reload')
.mockResolvedValue({} as StationLoginSuccess);

const result = await webex.cc.stationReLogin();

expect(stationLoginMock).toHaveBeenCalled();
expect(result).toEqual(response);
});

it('should handle error during relogin', async () => {
const error = new Error('Error while performing station relogin');

jest.spyOn(webex.cc.services.agent, 'reload').mockRejectedValue(error);

await expect(webex.cc.stationReLogin()).rejects.toThrow(error);

expect(webex.logger.error).toHaveBeenCalledWith(`file: cc: Station ReLogin failed: ${error}`);
});
});
});

0 comments on commit ff494fc

Please sign in to comment.