Index: third_party/pkg/angular/test/formatter/order_by_spec.dart |
diff --git a/third_party/pkg/angular/test/filter/order_by_spec.dart b/third_party/pkg/angular/test/formatter/order_by_spec.dart |
similarity index 72% |
rename from third_party/pkg/angular/test/filter/order_by_spec.dart |
rename to third_party/pkg/angular/test/formatter/order_by_spec.dart |
index 80f4a34c9f01514e91cd91ce43467d1bcf0c7294..42ad2ea34f220d154599ffa71ee8fe27de19f422 100644 |
--- a/third_party/pkg/angular/test/filter/order_by_spec.dart |
+++ b/third_party/pkg/angular/test/formatter/order_by_spec.dart |
@@ -6,21 +6,22 @@ import '../_specs.dart'; |
class Name { |
String firstName; |
String lastName; |
- Name({String this.firstName, String this.lastName}); |
+ Name({this.firstName, this.lastName}); |
operator ==(Name other) => |
(firstName == other.firstName && lastName == other.lastName); |
String toString() => 'Name(firstName: $firstName, lastName: $lastName)'; |
+ int get hashCode => firstName.hashCode + lastName.hashCode; |
} |
main() { |
- describe('orderBy filter', () { |
+ describe('orderBy formatter', () { |
var Emily___Bronte = new Name(firstName: 'Emily', lastName: 'Bronte'), |
Mark____Twain = {'firstName': 'Mark', 'lastName': 'Twain'}, |
Jeffrey_Archer = {'firstName': 'Jeffrey', 'lastName': 'Archer'}, |
Isaac___Asimov = new Name(firstName: 'Isaac', lastName: 'Asimov'), |
Oscar___Wilde = {'firstName': 'Oscar', 'lastName': 'Wilde'}; |
- beforeEach(() => inject((Scope scope, Parser parse, FilterMap filters) { |
+ beforeEach((Scope scope, Parser parse, FormatterMap formatters) { |
scope.context['authors'] = [ |
Emily___Bronte, |
Mark____Twain, |
@@ -34,34 +35,34 @@ main() { |
{'a': 20, 'b': 10}, |
{'a': 20, 'b': 20}, |
]; |
- })); |
+ }); |
- it('should pass through null list when input list is null', inject((Scope scope, Parser parse, FilterMap filters) { |
+ it('should pass through null list when input list is null', (Scope scope, Parser parse, FormatterMap formatters) { |
var list = null; |
- expect(parse('list | orderBy:"foo"').eval(scope.context, filters)).toBe(null); |
- })); |
+ expect(parse('list | orderBy:"foo"').eval(scope.context, formatters)).toBe(null); |
+ }); |
- it('should pass through argument when expression is null', inject((Scope scope, Parser parse, FilterMap filters) { |
+ it('should pass through argument when expression is null', (Scope scope, Parser parse, FormatterMap formatters) { |
var list = scope.context['list'] = [1, 3, 2]; |
- expect(parse('list | orderBy:thisIsNull').eval(scope.context, filters)).toBe(list); |
- })); |
+ expect(parse('list | orderBy:thisIsNull').eval(scope.context, formatters)).toBe(list); |
+ }); |
- it('should sort with "empty" expression using default comparator', inject((Scope scope, Parser parse, FilterMap filters) { |
+ it('should sort with "empty" expression using default comparator', (Scope scope, Parser parse, FormatterMap formatters) { |
scope.context['list'] = [1, 3, 2]; |
- expect(parse('list | orderBy:""').eval(scope.context, filters)).toEqual([1, 2, 3]); |
- expect(parse('list | orderBy:"+"').eval(scope.context, filters)).toEqual([1, 2, 3]); |
- expect(parse('list | orderBy:"-"').eval(scope.context, filters)).toEqual([3, 2, 1]); |
- })); |
+ expect(parse('list | orderBy:""').eval(scope.context, formatters)).toEqual([1, 2, 3]); |
+ expect(parse('list | orderBy:"+"').eval(scope.context, formatters)).toEqual([1, 2, 3]); |
+ expect(parse('list | orderBy:"-"').eval(scope.context, formatters)).toEqual([3, 2, 1]); |
+ }); |
- it('should sort by expression', inject((Scope scope, Parser parse, FilterMap filters) { |
- expect(parse('authors | orderBy:"firstName"').eval(scope.context, filters)).toEqual([ |
+ it('should sort by expression', (Scope scope, Parser parse, FormatterMap formatters) { |
+ expect(parse('authors | orderBy:"firstName"').eval(scope.context, formatters)).toEqual([ |
Emily___Bronte, |
Isaac___Asimov, |
Jeffrey_Archer, |
Mark____Twain, |
Oscar___Wilde, |
]); |
- expect(parse('authors | orderBy:"lastName"').eval(scope.context, filters)).toEqual([ |
+ expect(parse('authors | orderBy:"lastName"').eval(scope.context, formatters)).toEqual([ |
Jeffrey_Archer, |
Isaac___Asimov, |
Emily___Bronte, |
@@ -70,7 +71,7 @@ main() { |
]); |
scope.context['sortKey'] = 'firstName'; |
- expect(parse('authors | orderBy:sortKey').eval(scope.context, filters)).toEqual([ |
+ expect(parse('authors | orderBy:sortKey').eval(scope.context, formatters)).toEqual([ |
Emily___Bronte, |
Isaac___Asimov, |
Jeffrey_Archer, |
@@ -78,110 +79,110 @@ main() { |
Oscar___Wilde, |
]); |
- })); |
+ }); |
- it('should reverse order when passed the additional descending param', inject((Scope scope, Parser parse, FilterMap filters) { |
- expect(parse('authors | orderBy:"lastName":true').eval(scope.context, filters)).toEqual([ |
+ it('should reverse order when passed the additional descending param', (Scope scope, Parser parse, FormatterMap formatters) { |
+ expect(parse('authors | orderBy:"lastName":true').eval(scope.context, formatters)).toEqual([ |
Oscar___Wilde, |
Mark____Twain, |
Emily___Bronte, |
Isaac___Asimov, |
Jeffrey_Archer, |
]); |
- })); |
+ }); |
- it('should reverse order when expression is prefixed with "-"', inject((Scope scope, Parser parse, FilterMap filters) { |
- expect(parse('authors | orderBy:"-lastName"').eval(scope.context, filters)).toEqual([ |
+ it('should reverse order when expression is prefixed with "-"', (Scope scope, Parser parse, FormatterMap formatters) { |
+ expect(parse('authors | orderBy:"-lastName"').eval(scope.context, formatters)).toEqual([ |
Oscar___Wilde, |
Mark____Twain, |
Emily___Bronte, |
Isaac___Asimov, |
Jeffrey_Archer, |
]); |
- })); |
+ }); |
it('should NOT reverse order when BOTH expression is prefixed with "-" AND additional parameter also asks reversal', |
- inject((Scope scope, Parser parse, FilterMap filters) { |
- expect(parse('authors | orderBy:"-lastName":true').eval(scope.context, filters)).toEqual([ |
+ (Scope scope, Parser parse, FormatterMap formatters) { |
+ expect(parse('authors | orderBy:"-lastName":true').eval(scope.context, formatters)).toEqual([ |
Jeffrey_Archer, |
Isaac___Asimov, |
Emily___Bronte, |
Mark____Twain, |
Oscar___Wilde, |
]); |
- })); |
+ }); |
it('should allow a "+" prefix on the expression that should be a nop (ascending order)', |
- inject((Scope scope, Parser parse, FilterMap filters) { |
- expect(parse('authors | orderBy:"+lastName"').eval(scope.context, filters)).toEqual([ |
+ (Scope scope, Parser parse, FormatterMap formatters) { |
+ expect(parse('authors | orderBy:"+lastName"').eval(scope.context, formatters)).toEqual([ |
Jeffrey_Archer, |
Isaac___Asimov, |
Emily___Bronte, |
Mark____Twain, |
Oscar___Wilde, |
]); |
- expect(parse('authors | orderBy:"+lastName":false').eval(scope.context, filters)).toEqual([ |
+ expect(parse('authors | orderBy:"+lastName":false').eval(scope.context, formatters)).toEqual([ |
Jeffrey_Archer, |
Isaac___Asimov, |
Emily___Bronte, |
Mark____Twain, |
Oscar___Wilde, |
]); |
- expect(parse('authors | orderBy:"+lastName":true').eval(scope.context, filters)).toEqual([ |
+ expect(parse('authors | orderBy:"+lastName":true').eval(scope.context, formatters)).toEqual([ |
Oscar___Wilde, |
Mark____Twain, |
Emily___Bronte, |
Isaac___Asimov, |
Jeffrey_Archer, |
]); |
- })); |
+ }); |
it('should support an array of expressions', |
- inject((Scope scope, Parser parse, FilterMap filters) { |
- expect(parse('items | orderBy:["-a", "-b"]').eval(scope.context, filters)).toEqual([ |
+ (Scope scope, Parser parse, FormatterMap formatters) { |
+ expect(parse('items | orderBy:["-a", "-b"]').eval(scope.context, formatters)).toEqual([ |
{'a': 20, 'b': 20}, |
{'a': 20, 'b': 10}, |
{'a': 10, 'b': 20}, |
{'a': 10, 'b': 10}, |
]); |
- expect(parse('items | orderBy:["-b", "-a"]').eval(scope.context, filters)).toEqual([ |
+ expect(parse('items | orderBy:["-b", "-a"]').eval(scope.context, formatters)).toEqual([ |
{'a': 20, 'b': 20}, |
{'a': 10, 'b': 20}, |
{'a': 20, 'b': 10}, |
{'a': 10, 'b': 10}, |
]); |
- expect(parse('items | orderBy:["a", "-b"]').eval(scope.context, filters)).toEqual([ |
+ expect(parse('items | orderBy:["a", "-b"]').eval(scope.context, formatters)).toEqual([ |
{'a': 10, 'b': 20}, |
{'a': 10, 'b': 10}, |
{'a': 20, 'b': 20}, |
{'a': 20, 'b': 10}, |
]); |
- expect(parse('items | orderBy:["a", "-b"]:true').eval(scope.context, filters)).toEqual([ |
+ expect(parse('items | orderBy:["a", "-b"]:true').eval(scope.context, formatters)).toEqual([ |
{'a': 20, 'b': 10}, |
{'a': 20, 'b': 20}, |
{'a': 10, 'b': 10}, |
{'a': 10, 'b': 20}, |
]); |
- })); |
+ }); |
it('should support function expressions', |
- inject((Scope scope, Parser parse, FilterMap filters) { |
+ (Scope scope, Parser parse, FormatterMap formatters) { |
scope.context['func'] = (e) => -(e['a'] + e['b']); |
- expect(parse('items | orderBy:[func, "a", "-b"]').eval(scope.context, filters)).toEqual([ |
+ expect(parse('items | orderBy:[func, "a", "-b"]').eval(scope.context, formatters)).toEqual([ |
{'a': 20, 'b': 20}, |
{'a': 10, 'b': 20}, |
{'a': 20, 'b': 10}, |
{'a': 10, 'b': 10}, |
]); |
scope.context['func'] = (e) => (e is Name) ? e.lastName : e['lastName']; |
- expect(parse('authors | orderBy:func').eval(scope.context, filters)).toEqual([ |
+ expect(parse('authors | orderBy:func').eval(scope.context, formatters)).toEqual([ |
Jeffrey_Archer, |
Isaac___Asimov, |
Emily___Bronte, |
Mark____Twain, |
Oscar___Wilde, |
]); |
- })); |
+ }); |
}); |
} |