Skip to content

Commit

Permalink
Add utils class to the tests
Browse files Browse the repository at this point in the history
Fixes #148
  • Loading branch information
ipeychev committed Mar 24, 2015
1 parent c8e49da commit 444d3ad
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/ui/react/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ var filesToLoad = [
/* bender requires CKEDITOR, should be after ckeditor.js */
'src/ui/react/test/util/bender.js',

'src/ui/react/test/util/utils.js',

/* ReactJS */
{
pattern: path.join(alloyEditorDir, 'react-with-addons.js'),
Expand Down
32 changes: 2 additions & 30 deletions src/ui/react/test/button-bold.jsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,12 @@
'use strict';

var assert = chai.assert;

var TestUtils = React.addons.TestUtils;
var Simulate = TestUtils.Simulate;
var Simulate = React.addons.TestUtils.Simulate;

describe('ButtonBold', function() {
this.timeout(35000);

before(function(done) {
var self = this;

var editable = document.createElement('div');

editable.setAttribute('id', 'editable');
editable.setAttribute('contenteditable', true);

document.getElementsByTagName('body')[0].appendChild(editable);

assert.ok(bender);
assert.ok(CKEDITOR);
assert.ok(AlloyEditor);

self.editor = new AlloyEditor({
toolbars: {},
srcNode: 'editable'
});

self.nativeEditor = self.editor.get('nativeEditor');

self.nativeEditor.on('instanceReady', function() {
self.nativeEditor.focus();

done();
});
});
before(Utils.createAlloyEditor);

beforeEach(function() {
this.btnContainer = document.createElement('div');
Expand Down
37 changes: 37 additions & 0 deletions src/ui/react/test/util/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(function() {
'use strict';

var Utils = {
createAlloyEditor: function(done, config) {
var self = this;

var editable = document.createElement('div');

editable.setAttribute('id', 'editable');
editable.setAttribute('contenteditable', true);

document.getElementsByTagName('body')[0].appendChild(editable);

assert.ok(bender);
assert.ok(CKEDITOR);
assert.ok(AlloyEditor);

config = CKEDITOR.tools.merge({
toolbars: {},
srcNode: 'editable'
}, config);

self.editor = new AlloyEditor(config);

self.nativeEditor = self.editor.get('nativeEditor');

self.nativeEditor.on('instanceReady', function() {
self.nativeEditor.focus();

done();
});
}
};

window.Utils = Utils;
}());

0 comments on commit 444d3ad

Please sign in to comment.