Skip to content

Commit

Permalink
Merge branch 'master' into bug/reconnect-callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
agowatch authored Jan 2, 2020
2 parents 04695c4 + 9f1ea6f commit af7bb4d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/screenviewing/DefaultScreenViewing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export default class DefaultScreenViewing implements ScreenViewing {
* Stops screen viewing and closes the screen signaling connection
*/
close(): Promise<void> {
return this.stop().then(() => this.componentContext.signalingSession.close());
return this.stop()
.catch(() => {})
.finally(() => {
return this.componentContext.signalingSession.close();
});
}

/**
Expand Down
24 changes: 24 additions & 0 deletions test/screenviewing/DefaultScreenViewing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@ describe('DefaultScreenViewing', () => {
});

describe('close', () => {
describe('with error', () => {
it('is closed', () => {
return new DefaultScreenViewing({
...Substitute.for(),
viewer: {
...Substitute.for(),
stop(): void {},
},
signalingSession: {
...Substitute.for(),
close(): Promise<void> {
return Promise.resolve();
},
},
viewingSession: {
...Substitute.for(),
closeConnection(): Promise<void> {
return Promise.reject(new Error('bummers'));
},
},
}).close();
});
});

it('calls viewer close', () => {
return new DefaultScreenViewing({
...Substitute.for(),
Expand Down

0 comments on commit af7bb4d

Please sign in to comment.