simplify the raw json parsing
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com> Fixed Tests Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -64,16 +64,14 @@ class MetaComponentParseTest : public QObject {
|
||||
QJsonValue description_json = obj.value("description");
|
||||
QJsonValue expected_json = obj.value("expected_output");
|
||||
|
||||
QVERIFY(description_json.isUndefined() == false);
|
||||
QVERIFY(expected_json.isString() == true);
|
||||
QVERIFY(!description_json.isUndefined());
|
||||
QVERIFY(expected_json.isString());
|
||||
|
||||
QString expected = expected_json.toString();
|
||||
|
||||
QString processed;
|
||||
bool valid = ResourcePackUtils::processComponent(description_json, processed);
|
||||
QString processed = ResourcePackUtils::processComponent(description_json);
|
||||
|
||||
QVERIFY(processed == expected);
|
||||
QVERIFY(valid == true);
|
||||
QCOMPARE(processed, expected);
|
||||
}
|
||||
|
||||
private slots:
|
||||
|
@ -7,12 +7,15 @@
|
||||
"italic": true,
|
||||
"extra": [
|
||||
{
|
||||
"extra": "Component!",
|
||||
"extra": [
|
||||
"Component!"
|
||||
],
|
||||
"bold": false,
|
||||
"italic": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"expected_output": "<font color=\"red\"><b><i>Hello, </i></b></font><font color=\"red\">Component!</font>"
|
||||
"expected_output":
|
||||
"<span style=\"color: red; font-weight: bold; font-style: italic;\">Hello, <span style=\"font-weight: normal; font-style: normal;\">Component!</span></span>"
|
||||
}
|
@ -9,5 +9,5 @@
|
||||
"strikethrough": true
|
||||
}
|
||||
],
|
||||
"expected_output": "<font color=\"blue\"><b><i><u><s>Hello, Component!</s></u></i></b></font>"
|
||||
"expected_output": "<span style=\"color: blue; font-weight: bold; font-style: italic;\"><s><u>Hello, Component!</u></s></span>"
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
{
|
||||
"text": "Hello, Component!",
|
||||
"clickEvent": {
|
||||
"open_url": true,
|
||||
"action": "open_url",
|
||||
"value": "https://google.com"
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,16 @@
|
||||
"color": "#873600",
|
||||
"bold": true,
|
||||
"underlined": true,
|
||||
"extra": {
|
||||
"text": "jumped over ",
|
||||
"color": "blue",
|
||||
"bold": false,
|
||||
"underlined": false,
|
||||
"italic": true,
|
||||
"strikethrough": true
|
||||
}
|
||||
"extra": [
|
||||
{
|
||||
"text": "jumped over ",
|
||||
"color": "blue",
|
||||
"bold": false,
|
||||
"underlined": false,
|
||||
"italic": true,
|
||||
"strikethrough": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "the lazy dog's back. ",
|
||||
@ -31,11 +33,13 @@
|
||||
"text": "1234567890 ",
|
||||
"color": "black",
|
||||
"strikethrough": false,
|
||||
"extra": "How vexingly quick daft zebras jump!"
|
||||
"extra": [
|
||||
"How vexingly quick daft zebras jump!"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"expected_output":
|
||||
"<font color=\"blue\"><i>The quick </i></font><font color=\"#873600\"><b><u>brown fox </u></b></font><font color=\"blue\"><i><s>jumped over </s></i></font><font color=\"green\"><b><i><u><s>the lazy dog's back. </s></u></i></b></font><font color=\"black\"><b><i><u>1234567890 </u></i></b></font><font color=\"black\"><b><i><u>How vexingly quick daft zebras jump!</u></i></b></font>"
|
||||
"<span style=\"color: blue; font-style: italic;\">The quick </span><span style=\"color: #873600; font-weight: bold;\"><u>brown fox </u><span style=\"color: blue; font-weight: normal; font-style: italic;\"><s>jumped over </s></span></span><span style=\"color: green; font-weight: bold; font-style: italic;\"><s><u>the lazy dog's back. </u></s><span style=\"color: black;\"><u>1234567890 </u>How vexingly quick daft zebras jump!</span></span>"
|
||||
}
|
||||
|
Reference in New Issue
Block a user