-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor options processor v2 (#4492)
## Goal of this PR The goal of this PR is to make `OptionsProcessor.ts` great again 🇺🇸 . To me it was total mess including tests. ## What was wrong or funky? 1. the tests tested if React Native's `processColor` color works as it should even though react native has [multiple tests for this](https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/__tests__/processColor-test.js). Aka we don't have to test React Native's functions :D 2. `LayoutTreeCrawler.test.ts` was testing `OptionsProcessor`s functionality so it was removed now 3. Lots of small things since this was done before putting `noImplicitAny` to true so it wasn't made TypeScript in mind ## Result Now `OptionsProcessor.ts` should be 1. code way more clear 2. tests are testing only things that they should 3. tests are written in clear way 4. it is easy to see from the tests what the whole function does 5. type safe for TypeScript `noImplicitAny` (when we actually turn it on)
- Loading branch information
Showing
9 changed files
with
175 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource'; | ||
import { ImageRequireSource } from 'react-native'; | ||
|
||
export class AssetService { | ||
resolveFromRequire(value: ImageRequireSource) { | ||
return resolveAssetSource(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { processColor } from 'react-native'; | ||
|
||
export class ColorService { | ||
toNativeColor(inputColor: string) { | ||
return processColor(inputColor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.