![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/ |
/** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ define([ 'squire' ], function (Squire) { 'use strict'; describe('Magento_Ui/js/form/element/date', function () { var injector = new Squire(), mocks = { 'Magento_Ui/js/lib/registry/registry': { /** Method stub. */ get: function () { return { get: jasmine.createSpy(), set: jasmine.createSpy() }; }, create: jasmine.createSpy(), set: jasmine.createSpy(), async: jasmine.createSpy() }, '/mage/utils/wrapper': jasmine.createSpy() }, model, utils, dataScope = 'abstract'; beforeEach(function (done) { injector.mock(mocks); injector.require([ 'Magento_Ui/js/form/element/date', 'mageUtils', 'knockoutjs/knockout-es5' ], function (Constr, mageUtils) { model = new Constr({ provider: 'provName', name: '', index: '', dataScope: dataScope, outputDateFormat: 'DD-MM-YYYY', inputDateFormat: 'YYYY-MM-DD', pickerDateTimeFormat: 'DD-MM-YYYY', options: { showsTime: false, dateFormat: 'dd-MM-y' } }); utils = mageUtils; done(); }); }); it('Check prepareDateTimeFormats function', function () { spyOn(utils, 'convertToMomentFormat'); model.prepareDateTimeFormats(); expect(utils.convertToMomentFormat).toHaveBeenCalled(); }); it('Check date will have correct value with different locales.', function () { model.value('2020-11-28'); expect(model.getPreview()).toBe('28-11-2020'); }); it('Check date will have correct value with timeOnly config value.', function () { model.options.timeOnly = true; model.options.timeFormat = 'h:mm a'; model.prepareDateTimeFormats(); model.value('02:43:58'); expect(model.getPreview()).toBe('2:43 am'); model.options.timeFormat = 'HH:mm:ss'; model.prepareDateTimeFormats(); model.value('02:43:58'); expect(model.getPreview()).toBe('02:43:58'); model.options.timeFormat = 'HH:mm:ss'; model.prepareDateTimeFormats(); model.value('2:43 am'); expect(model.getPreview()).toBe('02:43:00'); }); }); });