You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
983 B
34 lines
983 B
const JsdomEnvironment = require('jest-environment-jsdom'); |
|
const path = require('path'); |
|
const fs = require('fs'); |
|
|
|
class FineUiEnvironment extends JsdomEnvironment { |
|
async setup(...args) { |
|
await super.setup(args); |
|
|
|
const document = this.dom.window.document; |
|
|
|
document.createElement('body'); |
|
|
|
[ |
|
'../node_modules/fineui/dist/fineui.js', |
|
'../node_modules/@fui/materials/docs/materials.js', |
|
'../config/fineui.prepare.js', |
|
'./fineui.setup.js', |
|
].forEach(scriptRelativePath => { |
|
writeScript(document, scriptRelativePath); |
|
}); |
|
|
|
return Promise.resolve(); |
|
} |
|
} |
|
|
|
function writeScript(document, scriptRelativePath) { |
|
const scriptEl = document.createElement('script'); |
|
scriptEl.text = fs.readFileSync(path.resolve(__dirname, scriptRelativePath), { |
|
encoding: 'utf8', |
|
}); |
|
document.body.appendChild(scriptEl); |
|
} |
|
|
|
module.exports = FineUiEnvironment;
|
|
|