Skip to content

Commit 7315d08

Browse files
committed
chore: Add @react-native/platform-colors tests
1 parent bb32d5d commit 7315d08

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@
4747
"typescript": "^5.2.2"
4848
},
4949
"scripts": {
50-
"test": "yarn --cwd test && yarn --cwd test eslint --report-unused-disable-directives --ext .js,.ts,.jsx,.tsx ."
50+
"test": "yarn --cwd test && yarn --cwd test eslint --max-warnings 0 --report-unused-disable-directives --ext .js,.ts,.jsx,.tsx ."
5151
}
5252
}

test/PlatformColor.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { PlatformColor, DynamicColorIOS } from 'react-native';
2+
3+
// Invalid
4+
// eslint-disable-next-line @react-native/platform-colors
5+
PlatformColor(); // required at least one argument
6+
// eslint-disable-next-line @react-native/platform-colors
7+
PlatformColor([], {}); // arguments must be string literals
8+
// eslint-disable-next-line @react-native/platform-colors
9+
DynamicColorIOS('red'); // required object as first argument
10+
11+
// Valid
12+
PlatformColor('bogusName', 'linkColor');
13+
14+
PlatformColor('label');
15+
PlatformColor('@android:color/holo_blue_bright');
16+
17+
export const customDynamicTextColor = DynamicColorIOS({
18+
dark: 'lightskyblue',
19+
light: 'midnightblue',
20+
});
21+
22+
export const customContrastDynamicTextColor = DynamicColorIOS({
23+
dark: 'darkgray',
24+
light: 'lightgray',
25+
highContrastDark: 'black',
26+
highContrastLight: 'white',
27+
});

test/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,11 @@
16121612
resolved "https://registry.yarnpkg.com/@react-native/assets/-/assets-1.0.0.tgz#c6f9bf63d274bafc8e970628de24986b30a55c8e"
16131613
integrity sha512-KrwSpS1tKI70wuKl68DwJZYEvXktDHdZMG0k2AXD/rJVSlB23/X2CB2cutVR0HwNMJIal9HOUOBB2rVfa6UGtQ==
16141614

1615+
"@react-native/eslint-plugin@^0.74.0 || ^0.73.0 || ^0.72.0":
1616+
version "0.74.84"
1617+
resolved "https://registry.yarnpkg.com/@react-native/eslint-plugin/-/eslint-plugin-0.74.84.tgz#f0e9618551c9340caca7624001f8ce32794715c9"
1618+
integrity sha512-pDzo4Qm1uPZQne2sv0QK89ePxP/i+ZHjrBW3rkTVStLvsDVdyFahMmt6bzJTdYL2cGgK2oyNmfXtvO57INOu3Q==
1619+
16151620
"@react-native/[email protected]":
16161621
version "2.0.0"
16171622
resolved "https://registry.yarnpkg.com/@react-native/normalize-color/-/normalize-color-2.0.0.tgz#da955909432474a9a0fe1cbffc66576a0447f567"

0 commit comments

Comments
 (0)