parent
dfe0130753
commit
35a83b495a
|
@ -108,6 +108,9 @@ class QueryList<T> extends Object
|
|||
int get length => _results.length;
|
||||
T get first => _results.first;
|
||||
T get last => _results.last;
|
||||
String toString() {
|
||||
return _results.toString();
|
||||
}
|
||||
|
||||
List map(fn(T)) {
|
||||
// Note: we need to return a list instead of iterable to match JS.
|
||||
|
|
|
@ -97,6 +97,8 @@ export class QueryList<T> {
|
|||
|
||||
removeCallback(callback: () => void): void { ListWrapper.remove(this._callbacks, callback); }
|
||||
|
||||
toString(): string { return this._results.toString(); }
|
||||
|
||||
get length(): number { return this._results.length; }
|
||||
get first(): T { return ListWrapper.first(this._results); }
|
||||
get last(): T { return ListWrapper.last(this._results); }
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular2/test_lib';
|
||||
|
||||
import {List, MapWrapper, ListWrapper, iterateListLike} from 'angular2/src/facade/collection';
|
||||
import {StringWrapper} from 'angular2/src/facade/lang';
|
||||
import {QueryList} from 'angular2/src/core/compiler/query_list';
|
||||
|
||||
|
||||
|
@ -43,6 +44,14 @@ export function main() {
|
|||
expect(queryList.map((x) => x)).toEqual(['one', 'two']);
|
||||
});
|
||||
|
||||
it('should support toString', () => {
|
||||
queryList.add('one');
|
||||
queryList.add('two');
|
||||
var listString = queryList.toString();
|
||||
expect(StringWrapper.contains(listString, 'one')).toBeTruthy();
|
||||
expect(StringWrapper.contains(listString, 'two')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should support first and last', () => {
|
||||
queryList.add('one');
|
||||
queryList.add('two');
|
||||
|
|
Loading…
Reference in New Issue