From d227c8479b8fddf689a932f4e80feadc450e5b27 Mon Sep 17 00:00:00 2001 From: Akash Agrawal Date: Tue, 10 May 2016 21:53:32 +0530 Subject: [PATCH] Add tests for loading attributes in components --- .../xml-declaration/xml-declaration-tests.ts | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/tests/xml-declaration/xml-declaration-tests.ts b/apps/tests/xml-declaration/xml-declaration-tests.ts index 8c316b505..17771211b 100644 --- a/apps/tests/xml-declaration/xml-declaration-tests.ts +++ b/apps/tests/xml-declaration/xml-declaration-tests.ts @@ -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"); -} \ No newline at end of file +}