| 1 | 'use strict'; |
| 2 | |
| 3 | const ReactJSDOMEnvironment = require('./ReactJSDOMEnvironment'); |
| 4 | const {TestEnvironment: NodeEnvironment} = require('jest-environment-node'); |
| 5 | |
| 6 | /** |
| 7 | * Test environment for testing integration of react-dom (browser) with react-dom/server (node) |
| 8 | */ |
| 9 | class ReactDOMServerIntegrationEnvironment extends NodeEnvironment { |
| 10 | constructor(config, context) { |
| 11 | super(config, context); |
| 12 | |
| 13 | this.domEnvironment = new ReactJSDOMEnvironment(config, context); |
| 14 | |
| 15 | this.global.window = this.domEnvironment.dom.window; |
| 16 | this.global.document = this.global.window.document; |
| 17 | this.global.navigator = this.global.window.navigator; |
| 18 | this.global.Node = this.global.window.Node; |
| 19 | this.global.addEventListener = this.global.window.addEventListener; |
| 20 | this.global.MutationObserver = this.global.window.MutationObserver; |
| 21 | } |
| 22 | |
| 23 | async setup() { |
| 24 | await super.setup(); |
| 25 | await this.domEnvironment.setup(); |
| 26 | } |
| 27 | |
| 28 | async teardown() { |
| 29 | await this.domEnvironment.teardown(); |
| 30 | await super.teardown(); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | module.exports = ReactDOMServerIntegrationEnvironment; |