mirror of
https://github.com/status-im/react-native.git
synced 2025-01-16 20:44:10 +00:00
d67258eb91
Reviewed By: mhorowitz Differential Revision: D3507905 fbshipit-source-id: cbe55495a991bf6eef961319ba8b219e660dce05
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
#include <gtest/gtest.h>
|
|
#include <folly/json.h>
|
|
#include <cxxreact/Value.h>
|
|
|
|
using namespace facebook;
|
|
using namespace facebook::react;
|
|
|
|
// TODO(cjhopman): Fix these tests.
|
|
/*
|
|
TEST(Value, Undefined) {
|
|
JSContextRef ctx = JSGlobalContextCreateInGroup(nullptr, nullptr);
|
|
Value v(ctx, JSValueMakeUndefined(ctx));
|
|
auto s = String::adopt(JSValueToStringCopy(ctx, v, nullptr));
|
|
EXPECT_EQ("undefined", s.str());
|
|
}
|
|
|
|
TEST(Value, FromJSON) {
|
|
JSContextRef ctx = JSGlobalContextCreateInGroup(nullptr, nullptr);
|
|
String s("{\"a\": 4}");
|
|
Value v(Value::fromJSON(ctx, s));
|
|
EXPECT_TRUE(JSValueIsObject(ctx, v));
|
|
}
|
|
|
|
TEST(Value, ToJSONString) {
|
|
JSContextRef ctx = JSGlobalContextCreateInGroup(nullptr, nullptr);
|
|
String s("{\"a\": 4}");
|
|
Value v(Value::fromJSON(ctx, s));
|
|
folly::dynamic dyn = folly::parseJson(v.toJSONString());
|
|
ASSERT_NE(nullptr, dyn);
|
|
EXPECT_TRUE(dyn.isObject());
|
|
auto val = dyn.at("a");
|
|
ASSERT_NE(nullptr, val);
|
|
ASSERT_TRUE(val.isInt());
|
|
EXPECT_EQ(4, val.getInt());
|
|
EXPECT_EQ(4.0f, val.asDouble());
|
|
}
|
|
|
|
*/
|