Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: compare the LogBoxData ignorePatterns with the right code (#31977)
Summary: the `LogBoxData.addIgnorePatterns` function shows the wrong code to get a item in `Set`. because every item in `set.entries` looks like `[value, value]`, but not `value`. while the `addIgnorePatterns` function evalutes two itertaions that is not necessary. So I refacted this function. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [General] [Fixed] - for LogBox checking existingPattern in a wrong way. [General] [Changed] - addIgnorePatterns runs in one iteration. [General] [Added] - add a function `getIgnorePatterns` in `LogBoxData.js` for tests or other usecases. Pull Request resolved: #31977 Test Plan: test codes in `LogBoxData-test.js`: ````js it('adding same pattern multiple times', () => { expect(LogBoxData.getIgnorePatterns().length).toBe(0); LogBoxData.addIgnorePatterns(['abc']); expect(LogBoxData.getIgnorePatterns().length).toBe(1); LogBoxData.addIgnorePatterns([/abc/]); expect(LogBoxData.getIgnorePatterns().length).toBe(2); LogBoxData.addIgnorePatterns(['abc']); expect(LogBoxData.getIgnorePatterns().length).toBe(2); LogBoxData.addIgnorePatterns([/abc/]); expect(LogBoxData.getIgnorePatterns().length).toBe(2); }); it('adding duplicated patterns', () => { expect(LogBoxData.getIgnorePatterns().length).toBe(0); LogBoxData.addIgnorePatterns(['abc', /ab/, /abc/, /abc/, 'abc']); expect(LogBoxData.getIgnorePatterns().length).toBe(3); LogBoxData.addIgnorePatterns([/ab/, /abc/]); expect(LogBoxData.getIgnorePatterns().length).toBe(3); }); ```` and they have passed Reviewed By: rickhanlonii Differential Revision: D30675522 Pulled By: yungsters fbshipit-source-id: 4a05e0f04a41d06cac416219f1e8e540bf0eea02
- Loading branch information