mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Add file, row and column for ui/builder errors
This commit is contained in:
14
apps/tests/xml-declaration/errors/non-existing-element.xml
Normal file
14
apps/tests/xml-declaration/errors/non-existing-element.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<Page shownModally="onShownModally">
|
||||
<StackLayout>
|
||||
<!--
|
||||
At first I was going to put "MenuItem",
|
||||
as per https://github.com/NativeScript/NativeScript/issues/501,
|
||||
but then again we may re-introduce "MenuItem" in future and blow this test up.
|
||||
So here is something unique that has better chance not to appear.
|
||||
This comment also offsets error's row and column numbers so if you edit,
|
||||
please do so beyond the unicorn.
|
||||
-->
|
||||
<Unicorn backgroundColor="pink" />
|
||||
<Label text="Modal Page" />
|
||||
</StackLayout>
|
||||
</Page>
|
||||
@@ -835,4 +835,24 @@ export function test_parse_template_property() {
|
||||
var button = <Button>templateView.getChildAt(0);
|
||||
TKUnit.assert(button, "Expected the TemplateView's template to create a button child.");
|
||||
TKUnit.assertEqual(button.text, "Click!", "Expected child Button to have text 'Click!'");
|
||||
}
|
||||
}
|
||||
|
||||
export function test_ParserError() {
|
||||
var basePath = "xml-declaration/";
|
||||
var expectedErrorStart =
|
||||
"Building UI from XML. @file:///app/" + basePath + "errors/non-existing-element.xml:11:5\n" +
|
||||
" ↳Module 'ui/unicorn' not found for element 'Unicorn'.\n";
|
||||
if (global.android) {
|
||||
expectedErrorStart += " ↳Module \"ui/unicorn\" not found";
|
||||
} else {
|
||||
expectedErrorStart += " ↳Failed to find module 'ui/unicorn'";
|
||||
}
|
||||
|
||||
var message;
|
||||
try {
|
||||
builder.load(__dirname + "/errors/non-existing-element.xml");
|
||||
} catch(e) {
|
||||
message = e.message;
|
||||
}
|
||||
TKUnit.assertEqual(message.substr(0, expectedErrorStart.length), expectedErrorStart, "Expected load to throw, and the message to start with specific string");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user