chore(tests): add diagram.css during tests

This commit is contained in:
Nico Rehwaldt 2014-08-12 11:53:00 +02:00
parent aca1ea21e9
commit 5df579bd02
1 changed files with 29 additions and 1 deletions

View File

@ -182,3 +182,31 @@ function inject(fn) {
module.exports.bootstrapModeler = (window || global).bootstrapModeler = bootstrapModeler;
module.exports.bootstrapViewer = (window || global).bootstrapViewer = bootstrapViewer;
module.exports.inject = (window || global).inject = inject;
function insertCSS(name, css) {
if (document.querySelector('[data-css-file="' + name + '"]')) {
return;
}
var head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.setAttribute('data-css-file', name);
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
}
module.exports.insertCSS = insertCSS;
var fs = require('fs');
// insert diagram.css
insertCSS('diagram.css', fs.readFileSync(__dirname + '/../node_modules/diagram-js/assets/diagram.css', 'utf-8'));