import * as TKUnit from "../tk-unit"; import * as view from "@nativescript/core/ui/core/view"; import { Builder } from "@nativescript/core/ui/builder"; import * as buttonModule from "@nativescript/core/ui/button"; import * as switchModule from "@nativescript/core/ui/switch"; import * as searchBarModule from "@nativescript/core/ui/search-bar"; import * as textFieldModule from "@nativescript/core/ui/text-field"; import * as gridLayoutModule from "@nativescript/core/ui/layouts/grid-layout"; import * as absoluteLayoutModule from "@nativescript/core/ui/layouts/absolute-layout"; import * as types from "@nativescript/core/utils/types"; import * as observable from "@nativescript/core/data/observable"; import * as stackLayoutModule from "@nativescript/core/ui/layouts/stack-layout"; import { Label } from "@nativescript/core/ui/label"; import { Page } from "@nativescript/core/ui/page"; import { Button } from "@nativescript/core/ui/button"; import { TabView } from "@nativescript/core/ui/tab-view"; import { Observable } from "@nativescript/core/data/observable"; 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 viewModule from "@nativescript/core/ui/core/view"; 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 { PercentLength, Length } from "@nativescript/core/ui/core/view"; 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.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.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 =