refactor(builder): handle modules with "/" or "~/" (#7418)

This commit is contained in:
Alexander Vakrilov
2019-06-28 15:38:42 +03:00
committed by Manol Donev
parent 4437cd622b
commit 8851835cb1
2 changed files with 16 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import { createViewFromEntry } from "tns-core-modules/ui/builder";
import { assertEqual, assertNull, assertThrows } from "../../tk-unit";
import { assertEqual, assertNull, assertThrows, assertNotNull } from "../../tk-unit";
const COMPONENT_MODULE = "ui/builder/component-module";
const MISSING_MODULE = "ui/builder/missing-module";
@@ -22,7 +22,17 @@ export function test_view_is_NOT_module_root_component() {
assertNull(undefinedModule, `View<${nestedView}> should NOT be a root component of a module.`);
}
export function test_load_component_from_missing_module_throws() {
export function test_create_view_from_entry_from_missing_module_throws() {
assertThrows(() => getViewComponent(MISSING_MODULE),
"Loading component from a missing module SHOULD throw an error.");
}
export function test_create_view_from_entry_with_path_with_slash() {
const view = getViewComponent("/" + COMPONENT_MODULE);
assertNotNull(view, `Module starting with "/" could not be loaded`);
}
export function test_create_view_from_entry_with_path_with_tilde() {
const view = getViewComponent("~/" + COMPONENT_MODULE);
assertNotNull(view, `Module starting with "~/" could not be loaded`);
}