From 221575e9823247b8c498210c986ab75b260ff78c Mon Sep 17 00:00:00 2001 From: Alexandru Ciuca Date: Mon, 28 Sep 2015 18:06:11 +0300 Subject: [PATCH] angularjs - Added some special filter use cases to tests --- angularjs/angular-tests.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 14e0dd7b4..88c348646 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -387,31 +387,31 @@ module TestPromise { var tresult: TResult; var tresultPromise: ng.IPromise; - + var tother: TOther; var totherPromise: ng.IPromise; - + var promise: angular.IPromise; // promise.then result = >promise.then((result) => any); result = >promise.then((result) => any, (any) => any); result = >promise.then((result) => any, (any) => any, (any) => any); - + result = >promise.then((result) => result); result = >promise.then((result) => result, (any) => any); result = >promise.then((result) => result, (any) => any, (any) => any); result = >promise.then((result) => tresultPromise); result = >promise.then((result) => tresultPromise, (any) => any); result = >promise.then((result) => tresultPromise, (any) => any, (any) => any); - + result = >promise.then((result) => tother); result = >promise.then((result) => tother, (any) => any); result = >promise.then((result) => tother, (any) => any, (any) => any); result = >promise.then((result) => totherPromise); result = >promise.then((result) => totherPromise, (any) => any); result = >promise.then((result) => totherPromise, (any) => any, (any) => any); - + // promise.catch result = >promise.catch((err) => any); result = >promise.catch((err) => tresult); @@ -937,7 +937,7 @@ function NgModelControllerTyping() { var $filter: angular.IFilterService; function testFilter() { - + var items: string[]; $filter("filter")(items, "test"); $filter("filter")(items, {name: "test"}); @@ -983,7 +983,7 @@ function testLimitTo() { var limitTo = $filter("limitTo"); var filtered: number[] = $filter("limitTo")([1,2,3], 5); filtered = $filter("limitTo")([1,2,3], 5, 2); - + var filteredString: string = $filter("limitTo")("124", 4); filteredString = $filter("limitTo")(124, 4); } @@ -1000,10 +1000,22 @@ function testOrderBy() { ]); } +function testDynamicFilter() { + // Test with separate variables + var dateFilter = $filter("date"); + var myDate = new Date(); + dateFilter(myDate , "EEE, MMM d"); + + // Test with dynamic name + var filterName = 'date'; + var dynDateFilter = $filter(filterName); + dynDateFilter(new Date()); +} + interface MyCustomFilter { (value: string): string; } - + function testCustomFilter() { var filterCustom = $filter('custom'); var filtered: string = filterCustom("test");