mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix test setup in attributedString module
Summary: changelog: [internal] Tests were not running because of `#ifdef ANDROID` directive. Tests had leaks and were using asserts instead of `EXPECT_EQ`. Reviewed By: JoshuaGross Differential Revision: D26168536 fbshipit-source-id: 453fe06a965c48f54d4bad6fe6653b6f45c39ccd
This commit is contained in:
committed by
Facebook GitHub Bot
parent
dce1863bf9
commit
67699ba9f2
@@ -5,9 +5,6 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <react/renderer/attributedstring/TextAttributes.h>
|
||||
#include <react/renderer/attributedstring/conversions.h>
|
||||
@@ -20,19 +17,20 @@ namespace react {
|
||||
#ifdef ANDROID
|
||||
|
||||
TEST(TextAttributesTest, testToDynamic) {
|
||||
auto text = TextAttributes();
|
||||
text.foregroundColor = {
|
||||
auto textAttributes = TextAttributes{};
|
||||
textAttributes.foregroundColor = {
|
||||
colorFromComponents({200 / 255.0, 153 / 255.0, 100 / 255.0, 1.0})};
|
||||
text.opacity = 0.5;
|
||||
text.fontStyle = FontStyle::Italic;
|
||||
text.fontWeight = FontWeight::Thin;
|
||||
text.fontVariant = FontVariant::TabularNums;
|
||||
textAttributes.opacity = 0.5;
|
||||
textAttributes.fontStyle = FontStyle::Italic;
|
||||
textAttributes.fontWeight = FontWeight::Thin;
|
||||
textAttributes.fontVariant = FontVariant::TabularNums;
|
||||
|
||||
auto result = toDynamic(text);
|
||||
assert(result["foregroundColor"] == toDynamic(text.foregroundColor));
|
||||
assert(result["opacity"] == text.opacity);
|
||||
assert(result["fontStyle"] == toString(*text.fontStyle));
|
||||
assert(result["fontWeight"] == toString(*text.fontWeight));
|
||||
auto result = toDynamic(textAttributes);
|
||||
EXPECT_EQ(
|
||||
result["foregroundColor"], toDynamic(textAttributes.foregroundColor));
|
||||
EXPECT_EQ(result["opacity"], textAttributes.opacity);
|
||||
EXPECT_EQ(result["fontStyle"], toString(textAttributes.fontStyle.value()));
|
||||
EXPECT_EQ(result["fontWeight"], toString(textAttributes.fontWeight.value()));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user