Convert CRM.utils.formatDate tests to karma
authorColeman Watts <coleman@civicrm.org>
Sun, 5 Jul 2020 03:29:57 +0000 (23:29 -0400)
committerColeman Watts <coleman@civicrm.org>
Sun, 5 Jul 2020 03:29:57 +0000 (23:29 -0400)
tests/karma/unit/dateSpec.js [new file with mode: 0644]
tests/qunit/common-js/test.js [deleted file]
tests/qunit/common-js/test.php [deleted file]

diff --git a/tests/karma/unit/dateSpec.js b/tests/karma/unit/dateSpec.js
new file mode 100644 (file)
index 0000000..454587a
--- /dev/null
@@ -0,0 +1,26 @@
+'use strict';
+
+describe('CRM.utils.formatDate', function() {
+
+  it('should format date input', function() {
+    var value = CRM.utils.formatDate('2021-05-10', 'mm/dd/yy');
+    expect(value).toBe("05/10/2021");
+  });
+
+  it("should format 12-hr time", function() {
+    var value = CRM.utils.formatDate('2021-05-10 12:35:00', 'mm/dd/yy', 12);
+    expect(value).toBe("05/10/2021 12:35 PM");
+
+    value = CRM.utils.formatDate('2021-05-10 00:35:00', 'mm/dd/yy', 12);
+    expect(value).toBe("05/10/2021 12:35 AM");
+  });
+
+  it("should format 24-hr time", function() {
+    var value = CRM.utils.formatDate('2020-05-20 04:25:40', 'mm/dd/yy', 24);
+    expect(value).toBe("05/20/2020 04:25");
+
+    value = CRM.utils.formatDate('2020-05-20 14:25:40', 'mm/dd/yy', 24);
+    expect(value).toBe("05/20/2020 14:25");
+  });
+
+});
diff --git a/tests/qunit/common-js/test.js b/tests/qunit/common-js/test.js
deleted file mode 100644 (file)
index df27eff..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-module('dates');
-
-test("format date", function() {
-  var value = CRM.utils.formatDate('2021-05-10', 'mm/dd/yy');
-  equal(value, "05/10/2021", "Expect formatted date");
-});
-
-test("format datetime 12", function() {
-  var value = CRM.utils.formatDate('2021-05-10 12:35:00', 'mm/dd/yy', 12);
-  equal(value, "05/10/2021 12:35 PM", "Expect formatted date time");
-
-  value = CRM.utils.formatDate('2021-05-10 00:35:00', 'mm/dd/yy', 12);
-  equal(value, "05/10/2021 12:35 AM", "Expect formatted date time");
-});
-
-
-test("format datetime 24", function() {
-  var value = CRM.utils.formatDate('2020-05-20 04:25:40', 'mm/dd/yy', 24);
-  equal(value, "05/20/2020 04:25", "Expect formatted date time");
-
-  value = CRM.utils.formatDate('2020-05-20 14:25:40', 'mm/dd/yy', 24);
-  equal(value, "05/20/2020 14:25", "Expect formatted date time");
-});
diff --git a/tests/qunit/common-js/test.php b/tests/qunit/common-js/test.php
deleted file mode 100644 (file)
index 7fab71c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-// CRM_Core_Resources::singleton()->addScriptFile(...);
-// CRM_Core_Resources::singleton()->addStyleFile(...);
-// CRM_Core_Resources::singleton()->addSetting(...);