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

Unified Diff: third_party/pkg/angular/test/filter/date_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/date_spec.dart
diff --git a/third_party/pkg/angular/test/filter/date_spec.dart b/third_party/pkg/angular/test/filter/date_spec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e508cfe69c6928eba71bf06a9ef0a7136818e4fb
--- /dev/null
+++ b/third_party/pkg/angular/test/filter/date_spec.dart
@@ -0,0 +1,60 @@
+library date_spec;
+
+import '../_specs.dart';
+
+main() => describe('date', () {
+ var morning = DateTime.parse('2010-09-03T07:05:08.008Z'); //7am
+ var noon = DateTime.parse('2010-09-03T12:05:08.012Z'); //12pm
+ var midnight = DateTime.parse('2010-09-03T12:05:08.123Z'); //12am
+ var earlyDate = DateTime.parse('0001-09-03T05:05:08.000Z');
+
+ var date;
+
+ beforeEach(inject((FilterMap map, Injector injector) {
+ date = injector.get(map[new NgFilter(name: 'date')]);
+ }));
+
+ it('should ignore falsy inputs', () {
+ expect(date(null)).toBeNull();
+ expect(date('')).toEqual('');
+ });
+
+ it('should do basic filter', () {
+ expect(date(noon)).toEqual(date(noon, 'mediumDate'));
+ });
+
+ it('should accept various format strings', () {
+ expect(date(morning, "yy-MM-dd HH:mm:ss")).
+ toEqual('10-09-03 07:05:08');
+
+ expect(date(morning, "yy-MM-dd HH:mm:ss.sss")).
+ toEqual('10-09-03 07:05:08.008');
+ });
+
+ it('should accept default formats', () {
+
+ expect(date(noon, "medium")).
+ toEqual('Sep 3, 2010 12:05:08 PM');
+
+ expect(date(noon, "short")).
+ toEqual('9/3/10 12:05 PM');
+
+ expect(date(noon, "fullDate")).
+ toEqual('Friday, September 3, 2010');
+
+ expect(date(noon, "longDate")).
+ toEqual('September 3, 2010');
+
+ expect(date(noon, "mediumDate")).
+ toEqual('Sep 3, 2010');
+
+ expect(date(noon, "shortDate")).
+ toEqual('9/3/10');
+
+ expect(date(noon, "mediumTime")).
+ toEqual('12:05:08 PM');
+
+ expect(date(noon, "shortTime")).
+ toEqual('12:05 PM');
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698