mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Added more tests
Global shortcut method tests Application load event tests collection change tests command event arg tests Component tests Culture info tests
This commit is contained in:
@@ -10,6 +10,15 @@ var arrayVar = new Array("Saturn", "Mars", "Jupiter");
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Global Shortcut Methods
|
||||
|
||||
$addHandler($get("Button1"), "click", () => { });
|
||||
$addHandlers($get("Button1"), {});
|
||||
$removeHandler($get("Button1"), "click", () => { });
|
||||
$find('MyComponent');
|
||||
$find('MyComponent', $find('#test'));
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Sys.Application Tests
|
||||
|
||||
@@ -65,6 +74,127 @@ Sys.Application.get_isDisposing();
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Sys.ApplicationLoadEventArgs Tests
|
||||
|
||||
var a = new Sys.ApplicationLoadEventArgs(new Array<Sys.Component>(), true);
|
||||
|
||||
var components = a.get_components();
|
||||
var isPartialReload = a.get_isPartialLoad();
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Sys.Browser Tests
|
||||
|
||||
var browser = Sys.Browser();
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Sys.CancelEventArgs Tests
|
||||
|
||||
var args = new Sys.CancelEventArgs();
|
||||
|
||||
var divElem = 'AlertDiv';
|
||||
var messageElem = 'AlertMessage';
|
||||
|
||||
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus);
|
||||
|
||||
function CheckStatus(sender, args) {
|
||||
|
||||
var prm = Sys.WebForms.PageRequestManager.getInstance();
|
||||
|
||||
if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'CancelRefresh') {
|
||||
prm.abortPostBack();
|
||||
}
|
||||
else if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') {
|
||||
|
||||
args.set_cancel(true);
|
||||
ActivateAlertDiv('visible', 'Still working on previous request.');
|
||||
}
|
||||
else if (!prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') {
|
||||
ActivateAlertDiv('visible', 'Processing....');
|
||||
}
|
||||
}
|
||||
|
||||
function ActivateAlertDiv(visString, msg) {
|
||||
var adiv = $get(divElem);
|
||||
var aspan = $get(messageElem);
|
||||
adiv.style.visibility = visString;
|
||||
aspan.innerHTML = msg;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Sys.CollectionChange Tests
|
||||
|
||||
var action = Sys.NotifyCollectionChangedAction.add;
|
||||
var newItems = [];
|
||||
var newStartingIndex = 1;
|
||||
var oldItems = [];
|
||||
var oldStartingIndex = 2;
|
||||
|
||||
var MyCChg = new Sys.CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex);
|
||||
|
||||
action = MyCChg.action;
|
||||
newItems = MyCChg.newItems;
|
||||
newStartingIndex = MyCChg.newStartingIndex;
|
||||
oldItems = MyCChg.oldItems;
|
||||
oldStartingIndex = MyCChg.oldStartingIndex;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Sys.CommandEventArg Tests
|
||||
|
||||
var commandName = "command name";
|
||||
var commandArgument = "command argument";
|
||||
var commandSource = "command source";
|
||||
var argsObj = new Sys.CommandEventArgs(commandName, commandArgument, commandSource);
|
||||
var empty = argsObj.Empty;
|
||||
commandName = argsObj.get_commandName();
|
||||
commandArgument = argsObj.get_commandArgument();
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Sys.Component Tests
|
||||
|
||||
var aComponent = new Sys.Component();
|
||||
|
||||
aComponent.add_disposing(() => { });
|
||||
aComponent.remove_disposing(() => { });
|
||||
|
||||
aComponent.add_propertyChanged(() => { });
|
||||
aComponent.remove_propertyChanged(() => { });
|
||||
|
||||
aComponent.beginUpdate();
|
||||
|
||||
aComponent.create(type, properties, events, references, element);
|
||||
|
||||
aComponent.dispose();
|
||||
|
||||
aComponent.endUpdate();
|
||||
|
||||
aComponent.initialize();
|
||||
|
||||
aComponent.raisePropertyChanged("propertyName");
|
||||
|
||||
aComponent.updated();
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Sys.CultureInfo Tests
|
||||
|
||||
var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture;
|
||||
var dtfCCObject = currentCultureInfoObj.dateTimeFormat;
|
||||
var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture;
|
||||
var dtfICObject = invariantCultureInfoObj.dateTimeFormat;
|
||||
|
||||
var newCulture = new Sys.CultureInfo("name", "numberFormat", "dateTimeFormat");
|
||||
|
||||
var format = newCulture.dateTimeFormat;
|
||||
var name = newCulture.name;
|
||||
var numberFormat = newCulture.numberFormat;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region ASP.NET Types Tests
|
||||
|
||||
Type.registerNamespace("Samples");
|
||||
@@ -102,12 +232,3 @@ alert(implementsInterface);
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Global Shortcut Methods
|
||||
|
||||
$addHandler($get("Button1"), "click", () => { });
|
||||
$addHandlers($get("Button1"), { });
|
||||
$removeHandler($get("Button1"), "click", () => { });
|
||||
$find('MyComponent');
|
||||
$find('MyComponent', $find('#test'));
|
||||
|
||||
//#endregion
|
||||
Vendored
+47
-4
@@ -554,7 +554,7 @@ declare module Sys {
|
||||
* The members can be invoked without creating an instance of the class.
|
||||
* @see {@link http://msdn.microsoft.com/en-us/library/bb384161(v=vs.100).aspx}
|
||||
*/
|
||||
class Application {
|
||||
interface Application {
|
||||
|
||||
//#region Constructors
|
||||
|
||||
@@ -697,11 +697,14 @@ declare module Sys {
|
||||
//#endregion
|
||||
}
|
||||
|
||||
var Application: Application;
|
||||
|
||||
/**
|
||||
* Provides information about the current Web browser.
|
||||
* The Sys.Browser object determines which browser is being used and provides some information about it. You can use this object to help customize your code to the unique requirements or capabilities of the browser.
|
||||
* @see {@link http://msdn.microsoft.com/en-us/library/cc679064(v=vs.100).aspx}
|
||||
*/
|
||||
class Browser {
|
||||
interface IBrowser {
|
||||
|
||||
//#region Fields
|
||||
|
||||
@@ -729,6 +732,8 @@ declare module Sys {
|
||||
//#endregion
|
||||
}
|
||||
|
||||
export function Browser(): Sys.IBrowser;
|
||||
|
||||
/**
|
||||
* Provides the base class for the Control and Behavior classes, and for any other object whose lifetime should be managed by the ASP.NET AJAX client library.
|
||||
* @see {@link http://msdn.microsoft.com/en-us/library/bb397516(v=vs.100).aspx}
|
||||
@@ -1465,6 +1470,42 @@ declare module Sys {
|
||||
|
||||
//#region Event Args
|
||||
|
||||
/*
|
||||
* Used by the Application class to hold event arguments for the load event.
|
||||
* @see {@link http://msdn.microsoft.com/en-us/library/bb383787(v=vs.100).aspx}
|
||||
*/
|
||||
class ApplicationLoadEventArgs {
|
||||
|
||||
//#region Constructors
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the ApplicationLoadEventArgs class.
|
||||
* @param components
|
||||
* The list of components that were created since the last time the load event was raised.
|
||||
* @param isPartialLoad
|
||||
* true to indicate that the event is a partial-page update.
|
||||
*/
|
||||
constructor(components: any, isPartialLoad: boolean);
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Properties
|
||||
|
||||
/**
|
||||
* Gets an array of all the components that were created since the last time the load event was raised.
|
||||
* @return An array of all the components that were created since the last time the load event was raised.
|
||||
*/
|
||||
get_components(): Component[];
|
||||
|
||||
/**
|
||||
* Returns a value that indicates whether the page is engaged in a partial-page update.
|
||||
* @return true if the page is engaged in a partial-page update; otherwise, false.
|
||||
*/
|
||||
get_isPartialLoad(): boolean;
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a base class for classes that are used by event sources to pass event argument information.
|
||||
* @see {@link http://msdn.microsoft.com/en-us/library/bb383795(v=vs.100).aspx}
|
||||
@@ -2635,7 +2676,7 @@ declare module Sys {
|
||||
* Returns the instance of the PageRequestManager class for the page.
|
||||
* @return The current instance of the PageRequestManager class. You do not create a new instance of the PageRequestManager class directly. Instead, an instance is available when partial-page rendering is enabled.
|
||||
*/
|
||||
getInstance(): PageRequestManager;
|
||||
static getInstance(): PageRequestManager;
|
||||
|
||||
/**
|
||||
* Stops all updates that would occur as a result of an asynchronous postback.
|
||||
@@ -2667,7 +2708,9 @@ declare module Sys {
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Properties
|
||||
//#region Properties
|
||||
|
||||
get_isInAsyncPostBack(): boolean;
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user