From fa83bcefdfc10d0e44a0fc6a358c07d573d89ba6 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 4 Jul 2020 23:29:57 -0400 Subject: [PATCH] Convert CRM.utils.formatDate tests to karma --- tests/karma/unit/dateSpec.js | 26 ++++++++++++++++++++++++++ tests/qunit/common-js/test.js | 23 ----------------------- tests/qunit/common-js/test.php | 4 ---- 3 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 tests/karma/unit/dateSpec.js delete mode 100644 tests/qunit/common-js/test.js delete mode 100644 tests/qunit/common-js/test.php diff --git a/tests/karma/unit/dateSpec.js b/tests/karma/unit/dateSpec.js new file mode 100644 index 0000000000..454587a2f6 --- /dev/null +++ b/tests/karma/unit/dateSpec.js @@ -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 index df27eff57b..0000000000 --- a/tests/qunit/common-js/test.js +++ /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 index 7fab71c485..0000000000 --- a/tests/qunit/common-js/test.php +++ /dev/null @@ -1,4 +0,0 @@ -addScriptFile(...); -// CRM_Core_Resources::singleton()->addStyleFile(...); -// CRM_Core_Resources::singleton()->addSetting(...); -- 2.25.1