import * as TKUnit from "../tk-unit"; import { Builder, Button, Switch, SearchBar, TextField, GridLayout, AbsoluteLayout, Observable, TabView, Page, Label } from "@nativescript/core"; import * as types from "@nativescript/core/utils/types"; import { TemplateView } from "./template-builder-tests/template-view"; import * as listViewModule from "@nativescript/core/ui/list-view"; import * as helper from "../ui-helper"; import * as platform from "@nativescript/core/platform"; import * as gesturesModule from "@nativescript/core/ui/gestures"; import * as segmentedBar from "@nativescript/core/ui/segmented-bar"; import { Source } from "@nativescript/core/utils/debug"; import { View, getAncestor, eachDescendant, PercentLength, Length } from "@nativescript/core"; export function test_load_IsDefined() { TKUnit.assertTrue(types.isFunction(Builder.load), "Builder should have load method!"); } export function test_parse_IsDefined() { TKUnit.assertTrue(types.isFunction(Builder.parse), "Builder should have parse method!"); } export function test_load_ShouldThrowWithInvalidFileName() { TKUnit.assertThrows(() => Builder.load("./xml-declaration/invalid-page.xml"), "Loading component from a missing module SHOULD throw an error."); } export function test_load_ShouldNotCrashWithoutExports() { var v = Builder.load("./xml-declaration/mainPage.xml"); TKUnit.assertTrue(v instanceof View, "Expected result: View; Actual result: " + v + ";"); } export function test_loadWithOptionsNoXML() { var v = Builder.load({ path: "~/xml-declaration/mymodule", name: "MyControl", exports: exports, page: new Page() }); TKUnit.assertTrue(v instanceof View, "Expected result: View; Actual result: " + v + ";"); } export function test_loadWithOptionsNoXML_CSSIsApplied() { let newPage = helper.getCurrentPage(); newPage.content = Builder.load({ path: "~/xml-declaration/mymodule", name: "MyControl", exports: exports, page: newPage }); TKUnit.assert(newPage.isLoaded, "The page should be loaded here."); helper.assertViewBackgroundColor(newPage.content, "#FF0000"); } export function test_loadInheritedPageAndResolveFromChild() { var basePath = "xml-declaration/"; helper.navigateToModuleAndRunTest(basePath + "inherited-page", null, (page) => { let contentLabel =