Files
edx-platform/lms/static/js/spec/dateutil_factory_spec.js
Syed Ali Abbas Zaidi f1fb38ed83 fix: multi lines and spaces issues (#31885)
* fix: multi lines and spaces issues

* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: remaining quotes issues

* fix: eslint object curly newline issue

* fix: eslint object curly spacing issue

* fix: eslint brace-style issues

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint linbreak style issue

* fix: eslint space unary operator issue

* fix: eslint line around directives issue

* fix: void and typeof space unary ops issue
2023-05-03 12:22:46 +05:00

51 lines
1.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
define(['../dateutil_factory.js'], function(DateUtilIterator) {
'use strict';
describe('DateUtilFactory', function() {
beforeEach(function() {
setFixtures('<div class="test"></div>');
});
describe('stringHandler', function() {
it('returns a complete string', function() {
var localTimeString = 'RANDOM_STRING';
var containerString = 'RANDOM_STRING_TWO {random_token}';
var dateToken = 'random_token';
var answer = 'RANDOM_STRING_TWO RANDOM_STRING';
expect(DateUtilIterator.stringHandler(localTimeString, containerString, dateToken)).toEqual(answer);
});
});
describe('transform', function() {
var $form;
it('localizes some times', function() {
/* we have to generate a fake span and then test the resultant texts */
var iterationKey = '.localized-datetime';
var testLangs = {
en: 'Due Oct 14, 2016 08:00 UTC',
ru: 'Due 14 окт. 2016 г. 08:00 UTC',
ar: 'Due ١٤ أكتوبر ٢٠١٦ ٠٨:٠٠ UTC',
fr: 'Due 14 oct. 2016 08:00 UTC'
};
$form = $(
'<span class="subtitle-name localized-datetime" '
+ 'data-timezone="UTC" '
+ 'data-datetime="2016-10-14 08:00:00+00:00" '
+ 'data-string="Due {date}"></span>'
);
Object.keys(testLangs).forEach(function(key) {
$form.attr('data-language', String(key));
$(document.body).append($form);
DateUtilIterator.transform(iterationKey);
expect($form.text()).toEqual(testLangs[key]);
$form.remove();
});
$form = null;
});
});
});
});