Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/api/DesktopAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,12 @@ export interface DesktopAgent {
* Returns `null` if the app is not joined to a channel.
*/
getCurrentChannel(): Promise<Channel>;

/**
* Removes the app from any channel membership.
*
* Context broadcast and listening through the top-level `fdc3.broadcast` and `fdc3.addContextListener` will be
* in a no-op when the app is not on a channel.
*/
leaveCurrentChannel(): Promise<void>;
}
4 changes: 4 additions & 0 deletions src/api/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ export const getOrCreateChannel: (
export const getCurrentChannel: () => Promise<Channel> = () => {
return window.fdc3.getCurrentChannel();
};

export const leaveCurrentChannel: () => Promise<void> = () => {
return window.fdc3.leaveCurrentChannel();
};
9 changes: 9 additions & 0 deletions test/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getOrCreateChannel,
getSystemChannels,
joinChannel,
leaveCurrentChannel,
open,
raiseIntent,
} from '../src';
Expand Down Expand Up @@ -167,4 +168,12 @@ describe('test ES6 module', () => {
expect(mock.mock.calls.length).toBe(1);
expect(mock.mock.calls[0]).toEqual([]);
});

it('leaveCurrentChannel should delegate to window.fdc3.leaveCurrentChannel', () => {
leaveCurrentChannel();

const mock = getMock('leaveCurrentChannel');
expect(mock.mock.calls.length).toBe(1);
expect(mock.mock.calls[0]).toEqual([]);
});
});