Skip to content

Commit

Permalink
Fix LogBox.ignoreAllLogs used with no argument (#29310)
Browse files Browse the repository at this point in the history
Summary:
When you call `LogBox.ignoreAllLogs()` it should ignore logs.

This fixes a bug that made this equivalent to `LogBox.ignoreAllLogs(false)`

## Changelog

[General] [Fixed] - LogBox.ignoreAllLogs() should ignore logs

Pull Request resolved: #29310

Test Plan: Added tests

Reviewed By: TheSavior

Differential Revision: D22448436

Pulled By: rickhanlonii

fbshipit-source-id: 6ba12b9d9c1f29cf3ac503946ac5ca0097425a7a
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Jul 9, 2020
1 parent ffa3d7f commit f28c750
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Libraries/LogBox/LogBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if (__DEV__) {
},

ignoreAllLogs: (value?: ?boolean): void => {
LogBoxData.setDisabled(!!value);
LogBoxData.setDisabled(value == null ? true : value);
},

uninstall: (): void => {
Expand Down
24 changes: 24 additions & 0 deletions Libraries/LogBox/__tests__/LogBox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,30 @@ describe('LogBox', () => {
expect(LogBoxData.isDisabled()).toBe(true);
});

it('will not ignore logs for `ignoreAllLogs(false)`', () => {
expect(LogBoxData.isDisabled()).toBe(false);

LogBox.install();

expect(LogBoxData.isDisabled()).toBe(false);

LogBox.ignoreAllLogs(false);

expect(LogBoxData.isDisabled()).toBe(false);
});

it('will ignore logs for `ignoreAllLogs()`', () => {
expect(LogBoxData.isDisabled()).toBe(false);

LogBox.install();

expect(LogBoxData.isDisabled()).toBe(false);

LogBox.ignoreAllLogs();

expect(LogBoxData.isDisabled()).toBe(true);
});

it('registers warnings', () => {
jest.mock('../Data/LogBoxData');

Expand Down

0 comments on commit f28c750

Please sign in to comment.