Files
NativeScript/apps/tests/ui/html-view/html-view-tests.ts
Erjan Gavalji 2d2fdfe4b0 Fix language tags in doc-snippets
The doc-snippets were inconsistent
(no spaces before title, small-caps, JS
instead of JavaScript, etc.)
2016-02-25 20:39:08 +02:00

60 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import TKUnit = require("../../TKUnit");
import helper = require("../helper");
import page = require("ui/page");
import types = require("utils/types");
// <snippet module="ui/html-view" title="HtmlView">
// # HtmlView
// Using a HtmlView requires the html-view module.
// ``` JavaScript
import htmlViewModule = require("ui/html-view");
// ```
// </snippet>
// <snippet module="ui/html-view" title="HtmlView">
// ### Declaring a HtmlView.
//``` XML
// <Page>
// {%raw%}<HtmlView html="{{ htmlString }}" />{%endraw%}
// </Page>
//```
// </snippet>
var _createHtmlViewFunc = function (): htmlViewModule.HtmlView {
// <snippet module="ui/html-view" title="HtmlView">
// ### Creating a HtmlView
// ``` JavaScript
var htmlView = new htmlViewModule.HtmlView();
// ```
// </snippet>
return htmlView;
}
export var testLoadHTMLString = function () {
var newPage: page.Page;
var htmlView = _createHtmlViewFunc();
var pageFactory = function (): page.Page {
newPage = new page.Page();
newPage.content = htmlView;
return newPage;
};
helper.navigate(pageFactory);
// <snippet module="ui/html-view" title="HtmlView">
// ### Using HtmlView
// ``` JavaScript
htmlView.html = '<span><font color="#ff0000">Test</font></span>';
// ```
// </snippet>
helper.goBack();
if (htmlView.ios) {
TKUnit.assert(!types.isNullOrUndefined(htmlView.ios.attributedText), "HTML string not loaded properly. Actual: " + htmlView.ios.attributedText);
} else if (htmlView.android) {
TKUnit.assert(htmlView.android.getText(), "HTML string not loaded properly. Actual: " + htmlView.android.getText());
}
}