2023-02-10 00:07:49 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
2024-12-03 13:13:35 -08:00
|
|
|
const ReactJSDOMEnvironment = require('./ReactJSDOMEnvironment');
|
2023-02-10 00:07:49 +08:00
|
|
|
const {TestEnvironment: NodeEnvironment} = require('jest-environment-node');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test environment for testing integration of react-dom (browser) with react-dom/server (node)
|
|
|
|
|
*/
|
|
|
|
|
class ReactDOMServerIntegrationEnvironment extends NodeEnvironment {
|
|
|
|
|
constructor(config, context) {
|
|
|
|
|
super(config, context);
|
|
|
|
|
|
2024-12-03 13:13:35 -08:00
|
|
|
this.domEnvironment = new ReactJSDOMEnvironment(config, context);
|
2023-02-10 00:07:49 +08:00
|
|
|
|
|
|
|
|
this.global.window = this.domEnvironment.dom.window;
|
|
|
|
|
this.global.document = this.global.window.document;
|
|
|
|
|
this.global.navigator = this.global.window.navigator;
|
|
|
|
|
this.global.Node = this.global.window.Node;
|
2023-04-25 09:12:16 -04:00
|
|
|
this.global.addEventListener = this.global.window.addEventListener;
|
|
|
|
|
this.global.MutationObserver = this.global.window.MutationObserver;
|
2023-02-10 00:07:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async setup() {
|
|
|
|
|
await super.setup();
|
|
|
|
|
await this.domEnvironment.setup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async teardown() {
|
|
|
|
|
await this.domEnvironment.teardown();
|
|
|
|
|
await super.teardown();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = ReactDOMServerIntegrationEnvironment;
|