Skip to content
This repository was archived by the owner on Sep 14, 2020. It is now read-only.

Commit 6748b6d

Browse files
committed
Merge pull request #224 from bramus/patch-1
2 parents 5f9a458 + c8cb138 commit 6748b6d

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/Bugsnag.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@ export class Client {
157157
metadata = {};
158158
}
159159

160-
let type = metadata['type'] || 'manual';
161-
const breadcrumbMetaData = { ...metadata };
162-
delete breadcrumbMetaData['type'];
160+
const {
161+
type = 'manual',
162+
...breadcrumbMetaData
163+
} = metadata;
163164

164165
NativeClient.leaveBreadcrumb({
165166
name,

src/__tests__/Bugsnag.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,25 @@ test('leaveBreadcrumb(): calls the native leaveBreadcrumb method correctly', ()
273273
mockLeaveBreadcrumb.mockClear()
274274
})
275275

276+
test('leaveBreadcrumb(): support setting "type" via metadata', () => {
277+
const mockLeaveBreadcrumb = jest.fn()
278+
jest.mock('react-native', () => ({
279+
NativeModules: { BugsnagReactNative: { startWithOptions: jest.fn(), leaveBreadcrumb: mockLeaveBreadcrumb } }
280+
}), { virtual: true })
281+
282+
const { Client, Configuration } = require('../Bugsnag')
283+
const config = new Configuration('API_KEY')
284+
const c = new Client(config)
285+
286+
c.leaveBreadcrumb('menu_expand', { type: 'UI', buttonClass: 'submit' })
287+
expect(mockLeaveBreadcrumb).toHaveBeenCalledWith({
288+
name: 'menu_expand',
289+
type: 'UI',
290+
metadata: { buttonClass: { type: 'string', value: 'submit' } }
291+
})
292+
mockLeaveBreadcrumb.mockClear()
293+
})
294+
276295
test('{enable|disable}ConsoleBreadCrumbs(): wraps/unwraps console methods and calls leaveBreadcrumb appropriately', () => {
277296
const mockLeaveBreadcrumb = jest.fn()
278297
jest.mock('react-native', () => ({

0 commit comments

Comments
 (0)