Skip to content

Commit

Permalink
fix(bluetooth-classic): uses the device address as default name
Browse files Browse the repository at this point in the history
Previously these lines of code may have resulted in an error, as the
matches objects may be undefined.
  • Loading branch information
mKeRix committed Feb 14, 2020
1 parent 6777e10 commit cc5b8a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Expand Up @@ -195,6 +195,20 @@ Requesting information ...
});
});

it('should return the address as device name if none was found', async () => {
jest.spyOn(util, 'promisify').mockImplementation(() => {
return jest.fn().mockResolvedValue({
stdout: 'IO error'
});
});

expect(await service.inquireDeviceInfo('F0:99:B6:12:34:AB')).toStrictEqual({
address: 'F0:99:B6:12:34:AB',
name: 'F0:99:B6:12:34:AB',
manufacturer: undefined
});
});

it('should return barebones information if request fails', async () => {
jest.spyOn(util, 'promisify').mockImplementation(() => {
return jest.fn().mockRejectedValue({ stderr: 'I/O Error' });
Expand Down
Expand Up @@ -216,8 +216,8 @@ export class BluetoothClassicService extends KalmanFilterable(Object, 1.4, 1)

return {
address,
name: nameMatches[1],
manufacturer: manufacturerMatches[1]
name: nameMatches ? nameMatches[1] : address,
manufacturer: manufacturerMatches ? manufacturerMatches[1] : undefined
};
} catch (e) {
this.logger.error(e.message, e.stack);
Expand Down

0 comments on commit cc5b8a9

Please sign in to comment.