8000 Add tests for loading attributes in components · hbcodeXCI/NativeScript@d227c84 · GitHub
[go: up one dir, main page]

Skip to content

Commit d227c84

Browse files
committed
Add tests for loading attributes in components
1 parent c2f0842 commit d227c84

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

apps/tests/xml-declaration/xml-declaration-tests.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,25 @@ export function test_loadWithOptionsFromTNSPath() {
133133
TKUnit.assert(v instanceof Label, "Expected result: Label; Actual result: " + v + ";");
134134
};
135135

136+
export function test_loadWithAttributes() {
137+
var lText = "Nativescript rocks";
138+
var lWrap = true;
139+
var lColor = "#FF0000"; // red
140+
var v = builder.load({
141+
path: "ui/label",
142+
name: "Label",
143+
attributes: {
144+
text: lText,
145+
textWrap: lWrap,
146+
style: "background-color: " + lColor + ";"
147+
}
148+
});
149+
150+
TKUnit.assertEqual(v.text, lText, "Expected result: true; Actual result: " + false + ";");
151+
TKUnit.assertEqual(v.textWrap, lWrap, "Expected result: true; Actual result: " + false + ";");
152+
TKUnit.assertViewColor(v, lColor, "Expected result: true; Actual result: " + false + ";");
153+
};
154+
136155
export function test_parse_ShouldNotCrashWithoutExports() {
137156
var file = fs.File.fromPath(fs.path.join(__dirname, "mainPage.xml"));
138157
var text = file.readTextSync();
@@ -879,4 +898,4 @@ export function test_hasSourceCodeLocations() {
879898
var label = page.getViewById("label");
880899
var labelSource = Source.get(label);
881900
TKUnit.assertEqual(labelSource.toString(), "file:///app/" + basePath + "examples/test-page.xml:3:5");
882-
}
901+
}

0 commit comments

Comments
 (0)
0