Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: third_party/pkg/angular/test/filter/limit_to_spec.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/test/filter/limit_to_spec.dart
diff --git a/third_party/pkg/angular/test/filter/limit_to_spec.dart b/third_party/pkg/angular/test/filter/limit_to_spec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9ce832fe76f1a21de4b4dd4593999939471fd178
--- /dev/null
+++ b/third_party/pkg/angular/test/filter/limit_to_spec.dart
@@ -0,0 +1,55 @@
+library limit_to_spec;
+
+import '../_specs.dart';
+
+main() {
+ describe('orderBy filter', () {
+ beforeEach(() => inject((Scope scope) {
+ scope['list'] = 'abcdefgh'.split('');
+ scope['string'] = 'tuvwxyz';
+ }));
+
+ it('should return the first X items when X is positive', inject((Scope scope) {
+ scope['limit'] = 3;
+ expect(scope.$eval('list | limitTo: 3')).toEqual(['a', 'b', 'c']);
+ expect(scope.$eval('list | limitTo: limit')).toEqual(['a', 'b', 'c']);
+ expect(scope.$eval('string | limitTo: 3')).toEqual('tuv');
+ expect(scope.$eval('string | limitTo: limit')).toEqual('tuv');
+ }));
+
+ it('should return the last X items when X is negative', inject((Scope scope) {
+ scope['limit'] = 3;
+ expect(scope.$eval('list | limitTo: -3')).toEqual(['f', 'g', 'h']);
+ expect(scope.$eval('list | limitTo: -limit')).toEqual(['f', 'g', 'h']);
+ expect(scope.$eval('string | limitTo: -3')).toEqual('xyz');
+ expect(scope.$eval('string | limitTo: -limit')).toEqual('xyz');
+ }));
+
+ it('should return an null when limiting null list',
+ inject((Scope scope) {
+ expect(scope.$eval('null | limitTo: 1')).toEqual(null);
+ expect(scope.$eval('thisIsNull | limitTo: 1')).toEqual(null);
+ }));
+
+ it('should return an empty array when X cannot be parsed',
+ inject((Scope scope) {
+ expect(scope.$eval('list | limitTo: bogus')).toEqual([]);
+ expect(scope.$eval('string | limitTo: null')).toEqual([]);
+ expect(scope.$eval('string | limitTo: thisIsNull')).toEqual([]);
+ }));
+
+ it('should return a copy of input array if X is exceeds array length',
+ inject((Scope scope) {
+ expect(scope.$eval('list | limitTo: 20')).toEqual(scope['list']);
+ expect(scope.$eval('list | limitTo: -20')).toEqual(scope['list']);
+ expect(scope.$eval('list | limitTo: 20')).not.toBe(scope['list']);
+ }));
+
+ it('should return the entire string if X exceeds input length',
+ inject((Scope scope) {
+ expect(scope.$eval('string | limitTo: 20')).toEqual(scope['string']);
+ expect(scope.$eval('string | limitTo: -20')).toEqual(scope['string']);
+ }));
+
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698