]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Positive and Negative RFC2822 testCases streamlined.
authorTGJG-XPS\TracyG <tracyg.gilmore@gmail.com>
Mon, 6 Mar 2017 20:09:39 +0000 (20:09 +0000)
committerIskren Chernev <iskren.chernev@gmail.com>
Sun, 12 Mar 2017 00:11:46 +0000 (02:11 +0200)
src/test/moment/create.js

index 679ae18f51599e8644a84f6db2284535bc011ab6..2678cb6bac8e7e1a66876bbd5a31e0eaa359d025 100644 (file)
@@ -457,27 +457,34 @@ test('cloning carrying over utc mode', function (assert) {
 });
 
 test('parsing RFC 2822', function (assert) {
-    assert.ok(moment('Tue, 01 Nov 2016 01:23:45 GMT', moment.RFC_2822, true).isValid(),
-        'clean RFC2822 datetime with all options');
-    assert.ok(moment('Tue 01 Nov 2016 01:23:45 GMT', moment.RFC_2822, true).isValid(),
-        'clean RFC2822 datetime without comma');
-    assert.ok(moment('Tue, 01 Nov 2016 01:23 GMT', moment.RFC_2822, true).isValid(),
-        'clean RFC2822 datetime without seconds');
-    assert.ok(moment('Tue, 01 Nov 16 01:23:45 GMT', moment.RFC_2822, true).isValid(),
-        'clean RFC2822 datetime without century');
-    assert.ok(moment('01 Nov 2016 01:23:45 GMT', moment.RFC_2822, true).isValid(),
-        'clean RFC2822 datetime without day');
-    assert.ok(moment('Tue, 1 Nov 2016 01:23:45 GMT', moment.RFC_2822, true).isValid(),
-        'clean RFC2822 datetime with single-digit day-of-month');
-    assert.ok(moment('(Init Comment) Tue,\n 1 Nov              2016 (Split\n Comment)  01:23:45 +0000 (GMT)', moment.RFC_2822, true).isValid(),
-        'RFC2822 datetime with CFWSs');
+    var testCases = {
+        'clean RFC2822 datetime with all options': 'Tue, 01 Nov 2016 01:23:45 GMT',
+        'clean RFC2822 datetime without comma': 'Tue 01 Nov 2016 01:23:45 GMT',
+        'clean RFC2822 datetime without seconds': 'Tue, 01 Nov 2016 01:23 GMT',
+        'clean RFC2822 datetime without century': 'Tue, 01 Nov 16 01:23:45 GMT',
+        'clean RFC2822 datetime without day': '01 Nov 2016 01:23:45 GMT',
+        'clean RFC2822 datetime with single-digit day-of-month': 'Tue, 1 Nov 2016 01:23:45 GMT',
+        'RFC2822 datetime with CFWSs': '(Init Comment) Tue,\n 1 Nov              2016 (Split\n Comment)  01:23:45 +0000 (GMT)'
+    };
+    var testCase;
+
+    for (testCase in testCases) {
+        var testResult = moment(testCases[testCase], moment.RFC_2822, true)
+        assert.ok(testResult.isValid(), testResult);
+    }
 });
 
 test('non RFC 2822 strings', function (assert) {
-    assert.ok(!moment('Tue. 01 Nov 2016 01:23:45 GMT', moment.RFC_2822, true).isValid(),
-        'RFC2822 datetime with all options but invalid day delimiter');
-    assert.ok(!moment('Mon, 01 Nov 2016 01:23:45 GMT', moment.RFC_2822, true).isValid(),
-        'RFC2822 datetime with mismatching Day (week v date)');
+    var testCases = {
+        'RFC2822 datetime with all options but invalid day delimiter': 'Tue. 01 Nov 2016 01:23:45 GMT',
+        'RFC2822 datetime with mismatching Day (week v date)': 'Mon, 01 Nov 2016 01:23:45 GMT'
+    };
+    var testCase;
+
+    for (testCase in testCases) {
+        var testResult = moment(testCases[testCase], moment.RFC_2822, true)
+        assert.ok(!testResult.isValid(), testResult);
+    }
 });
 
 test('parsing iso', function (assert) {