mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
attach/detach in ViewBase
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import * as TKUnit from "../../TKUnit";
|
||||
import { ActionItem } from "ui/action-bar";
|
||||
import { Visibility } from "ui/enums";
|
||||
import { Button } from "ui/button";
|
||||
|
||||
global.moduleMerge(actionTestsCommon, exports);
|
||||
|
||||
@@ -29,4 +30,46 @@ export function test_navigationButton_visibility() {
|
||||
TKUnit.assertNotNull(toolbar.getNavigationIcon(), "Visibility does not work");
|
||||
actionItem.visibility = Visibility.collapse;
|
||||
TKUnit.assertNull(toolbar.getNavigationIcon(), "Visibility does not work");
|
||||
}
|
||||
}
|
||||
|
||||
export function test_set_actionView_to_attached_actionItem_propagates_context() {
|
||||
const actionItem = new ActionItem();
|
||||
const actionButton = new Button();
|
||||
actionItem.actionView = actionButton;
|
||||
|
||||
const page = actionTestsCommon.createPageAndNavigate();
|
||||
|
||||
// sanity check
|
||||
TKUnit.assertNotNull(page.content._context, "Page content context should not be null");
|
||||
|
||||
// assert null before add
|
||||
TKUnit.assertNull(actionItem._context, "Action Item context should be null before added");
|
||||
TKUnit.assertNull(actionButton._context, "Action button context should not null before added");
|
||||
|
||||
page.actionBar.actionItems.addItem(actionItem);
|
||||
|
||||
// assert not null after add
|
||||
TKUnit.assertNotNull(actionItem._context, "Action Item context should not be null after add");
|
||||
TKUnit.assertNotNull(actionButton._context, "Action button context should not be null after add");
|
||||
}
|
||||
|
||||
export function test_add_actionItem_with_actionView_propagates_context() {
|
||||
const actionItem = new ActionItem();
|
||||
|
||||
const page = actionTestsCommon.createPageAndNavigate();
|
||||
|
||||
// sanity check
|
||||
TKUnit.assertNotNull(page.content._context, "Page content context should not be null");
|
||||
|
||||
// add actionItem to the actionBar
|
||||
TKUnit.assertNull(actionItem._context, "Action Item context should be null before added");
|
||||
page.actionBar.actionItems.addItem(actionItem);
|
||||
TKUnit.assertNotNull(actionItem._context, "Action Item context should not be null after add");
|
||||
|
||||
const actionButton = new Button();
|
||||
|
||||
// add actionButton to the actionItem
|
||||
TKUnit.assertNull(actionButton._context, "Action button context should be null before added");
|
||||
actionItem.actionView = actionButton;
|
||||
TKUnit.assertNotNull(actionButton._context, "Action button context should not be null after add");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user