Skip to content

Commit

Permalink
Improve coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
mbohal committed Jun 24, 2016
1 parent 15b118a commit 657269b
Showing 1 changed file with 36 additions and 42 deletions.
78 changes: 36 additions & 42 deletions src/js/tests/unit/ckeditor-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ $(function () {

teardown: function () {
delete jQuery.fn.ckeditor;
$('html').attr('lang', null);
},
});

Expand All @@ -16,53 +17,46 @@ $(function () {

// Data-api tests
// ======================
QUnit.test('should call the ckeditor() method on the textarea on page load with no attribute',
function () {
var $textarea = $('<textarea data-onload-ckeditor>Some text</textarea>');
$('#qunit-fixture').append($textarea);

sinon.spy(jQuery.fn, 'ckeditor');
$(window).trigger('load');
QUnit.test('should init ckeditor on page load with no attribute', function () {
var $textarea = $('<textarea data-onload-ckeditor></textarea>');
$('#qunit-fixture').append($textarea);

sinon.spy(jQuery.fn, 'ckeditor');
$(window).trigger('load');

QUnit.ok(jQuery.fn.ckeditor.calledOnce, 'Should init the ckeditor');
QUnit.ok(
jQuery.fn.ckeditor.calledWithExactly({}),
'Should init the ckeditor with no arguments'
);
});

QUnit.ok(jQuery.fn.ckeditor.calledOnce, 'Should init the ckeditor');
QUnit.ok(
jQuery.fn.ckeditor.calledWithExactly({}),
'Should init the ckeditor with no arguments'
);
}
);
QUnit.test('should init ckeditor on page load with string attribute', function () {
var $textarea = $('<textarea data-onload-ckeditor="/path/to/config.js"></textarea>');
$('#qunit-fixture').append($textarea);

QUnit.test('should call the ckeditor() method on the textarea on page load with string attribute',
function () {
var $textarea = $('<textarea data-onload-ckeditor="/path/to/config.js">Some text</textarea>');
$('#qunit-fixture').append($textarea);
sinon.spy(jQuery.fn, 'ckeditor');
$(window).trigger('load');

sinon.spy(jQuery.fn, 'ckeditor');
$(window).trigger('load');
QUnit.ok(jQuery.fn.ckeditor.calledOnce, 'Should init the ckeditor');
QUnit.ok(
jQuery.fn.ckeditor.calledWithExactly({ customConfig: '/path/to/config.js' }),
'Should init the ckeditor with proper custom config file specified'
);
});

QUnit.ok(jQuery.fn.ckeditor.calledOnce, 'Should init the ckeditor');
QUnit.ok(
jQuery.fn.ckeditor.calledWithExactly({ customConfig: '/path/to/config.js' }),
'Should init the ckeditor with proper custom config file specified'
);
}
);
QUnit.test('should init ckeditor on on page load with json attribute', function () {
var $textarea = $('<textarea data-onload-ckeditor=\'{"option": "value"}\'></textarea>');
$('#qunit-fixture').append($textarea);

QUnit.test('should call the ckeditor() method on the textarea on page load with json attribute',
function () {
var $textarea = $(
'<textarea data-onload-ckeditor=\'{"option": "value"}\'>Some text</textarea>' +
'');
$('#qunit-fixture').append($textarea);
sinon.spy(jQuery.fn, 'ckeditor');
$(window).trigger('load');

sinon.spy(jQuery.fn, 'ckeditor');
$(window).trigger('load');
QUnit.ok(jQuery.fn.ckeditor.calledOnce, 'Should init the ckeditor');
QUnit.ok(
jQuery.fn.ckeditor.calledWithExactly({ option: 'value' }),
'Should init the ckeditor with proper config object'
);
});

QUnit.ok(jQuery.fn.ckeditor.calledOnce, 'Should init the ckeditor');
QUnit.ok(
jQuery.fn.ckeditor.calledWithExactly({ option: 'value' }),
'Should init the ckeditor with proper config object'
);
}
);
});

0 comments on commit 657269b

Please sign in to comment.