Skip to content

Instantly share code, notes, and snippets.

@vojtajina
Created November 10, 2013 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vojtajina/7400775 to your computer and use it in GitHub Desktop.
Save vojtajina/7400775 to your computer and use it in GitHub Desktop.
TinyMCE test
// Karma configuration
// Generated on Wed Nov 06 2013 10:36:01 GMT+0100 (Paris, Madrid)
module.exports = function (config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['qunit'],
// list of files / patterns to load in the browser
files: [
"tiny_mce/tinymce.js",
// because TinyMCE will fetch other resources like css, fonts, etc.
{pattern: 'tiny_mce/**/*', included: false},
"test.js"
],
// list of files to exclude
exclude: [
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
//browsers: ['Chrome', 'Firefox', 'IE'],
browsers: ['Chrome'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
// disable karma auto start and start it manually, once the tinymce is initialized
// similar to what requirejs adapter does
__karma__.loaded = function() {};
document.body.innerHTML = '<textarea></textarea>';
var editor;
tinymce.init({
selector: "textarea",
plugins: [
"code"
],
toolbar1: "undo redo",
menubar: false,
forced_root_block_attrs: { "class": "MsoNormal", style: 'font-size: 12pt;', },
entity_encoding: "raw",
allow_html_in_named_anchor: true,
init_instance_callback: function (ed) {
editor = ed;
// trigger Karma manually
__karma__.start();
}
});
module("Module 1", {
autostart: false
});
test('Check editor content', function () {
editor.focus();
editor.setContent('');
editor.execCommand('mceInsertContent', false, 'test');
equal('<p class="MsoNormal" style="font-size: 12pt;">test</p>', editor.getContent());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment