Skip to content

Commit

Permalink
Merge pull request #5120 from FinalAngel/feature/unit-tests/cms-struc…
Browse files Browse the repository at this point in the history
…tureboard

CMS Structureboard unit tests
  • Loading branch information
vxsx committed Mar 31, 2016
2 parents eead5e9 + 41894af commit 4cd9426
Show file tree
Hide file tree
Showing 5 changed files with 760 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cms/static/cms/js/dist/bundle.toolbar.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions cms/static/cms/js/modules/cms.structureboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ var CMS = window.CMS || {};
// keyboard handling
// only if there is a structure / content switcher
if (that.ui.toolbarModeSwitcher.length) {
that.ui.doc.on('keydown', function (e) {
that.ui.doc.on('keydown.cms.structureboard.switcher', function (e) {
// check if we have an important focus
var haveFocusedField = document.activeElement !== document.body;
if (e.keyCode === CMS.KEYS.SPACE && !haveFocusedField) {
e.preventDefault();
if (CMS.settings.mode === 'structure') {
that.hide();
} else if (CMS.settings.mode === 'edit') {
} else /* istanbul ignore else */ if (CMS.settings.mode === 'edit') {
that.show();
}
}
Expand Down Expand Up @@ -394,7 +394,7 @@ var CMS = window.CMS || {};
* @private
* @deprecated as of CMS 3.2
*/
_resizeBoard: function () {
_resizeBoard: /* istanbul ignore next */ function () {
// calculate placeholder position
var id = null;
var area = null;
Expand Down Expand Up @@ -558,7 +558,7 @@ var CMS = window.CMS || {};
// save original state events
var original = $('.cms-plugin-' + that.getId(originalItem));
// cancel if item has no settings
if (original.length === 0 || original.data('settings') === null) {
if (original.length === 0 || !original.data('settings')) {
return false;
}
var parent_bounds = $.grep(original.data('settings').plugin_parent_restriction, function (r) {
Expand Down
2 changes: 2 additions & 0 deletions cms/tests/frontend/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"casper",
"beforeEach",
"afterEach",
"beforeAll",
"afterAll",
"spyOn",
"spyOnEvent",
"fixture",
Expand Down
8 changes: 7 additions & 1 deletion cms/tests/frontend/unit/cms.modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ describe('CMS.Modal', function () {
});

it('throws an error when no url or html options were passed', function () {
spyOn(modal, '_loadIframe');
expect(modal.open.bind(modal)).toThrowError(
Error, 'The arguments passed to "open" were invalid.'
);
Expand Down Expand Up @@ -2206,7 +2207,12 @@ describe('CMS.Modal', function () {

body.on('keydown.cms', function (e) {
if (modal.close.calls.count()) {
done();
// have to wait till next frame here
// because Edge is too fast and it cleans up
// the test case _before_ second trigger call finishes
setTimeout(function () {
done();
}, 0);
}
});

Expand Down
Loading

0 comments on commit 4cd9426

Please sign in to comment.