mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Add tests for loading attributes in components
This commit is contained in:
@ -133,6 +133,25 @@ export function test_loadWithOptionsFromTNSPath() {
|
||||
TKUnit.assert(v instanceof Label, "Expected result: Label; Actual result: " + v + ";");
|
||||
};
|
||||
|
||||
export function test_loadWithAttributes() {
|
||||
var lText = "Nativescript rocks";
|
||||
var lWrap = true;
|
||||
var lColor = "#FF0000"; // red
|
||||
var v = builder.load({
|
||||
path: "ui/label",
|
||||
name: "Label",
|
||||
attributes: {
|
||||
text: lText,
|
||||
textWrap: lWrap,
|
||||
style: "background-color: " + lColor + ";"
|
||||
}
|
||||
});
|
||||
|
||||
TKUnit.assertEqual(v.text, lText, "Expected result: true; Actual result: " + false + ";");
|
||||
TKUnit.assertEqual(v.textWrap, lWrap, "Expected result: true; Actual result: " + false + ";");
|
||||
TKUnit.assertViewColor(v, lColor, "Expected result: true; Actual result: " + false + ";");
|
||||
};
|
||||
|
||||
export function test_parse_ShouldNotCrashWithoutExports() {
|
||||
var file = fs.File.fromPath(fs.path.join(__dirname, "mainPage.xml"));
|
||||
var text = file.readTextSync();
|
||||
@ -879,4 +898,4 @@ export function test_hasSourceCodeLocations() {
|
||||
var label = page.getViewById("label");
|
||||
var labelSource = Source.get(label);
|
||||
TKUnit.assertEqual(labelSource.toString(), "file:///app/" + basePath + "examples/test-page.xml:3:5");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user