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

Unified Diff: third_party/pkg/angular/test/formatter/date_spec.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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/formatter/date_spec.dart
diff --git a/third_party/pkg/angular/test/formatter/date_spec.dart b/third_party/pkg/angular/test/formatter/date_spec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8055e16185ce61840301e68760cafb07013bda8b
--- /dev/null
+++ b/third_party/pkg/angular/test/formatter/date_spec.dart
@@ -0,0 +1,77 @@
+library date_spec;
+
+import '../_specs.dart';
+import 'package:intl/intl.dart';
+
+void 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((FormatterMap map, Injector injector) {
+ date = injector.get(map[new Formatter(name: 'date')]);
+ });
+
+ it('should ignore falsy inputs', () {
+ expect(date(null)).toBeNull();
+ expect(date('')).toEqual('');
+ });
+
+ it('should do basic formatter', () {
+ 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');
+ });
+
+ it('should use cache without any error', () {
+
+ date(noon, "shortTime");
+ date(noon, "shortTime");
+ });
+
+
+ it('should accept various locales', async(() {
+ expect(Intl.withLocale('de', () => date(noon, "medium"))).
+ toEqual('Sep 3, 2010 12:05:08 nachm.');
+ expect(Intl.withLocale('fr', () => date(noon, "medium"))).
+ toEqual('sept. 3, 2010 12:05:08 PM');
+ }));
+ });
+}
« no previous file with comments | « third_party/pkg/angular/test/formatter/currency_spec.dart ('k') | third_party/pkg/angular/test/formatter/filter_spec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698