From 102fafce7f92b11b834e0af04f9bff05faed9aed Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Wed, 19 Aug 2015 19:53:21 -0700 Subject: [PATCH] Add a simple production-mode sanity check test --- .../dom/__tests__/ReactDOMProduction-test.js | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/renderers/dom/__tests__/ReactDOMProduction-test.js diff --git a/src/renderers/dom/__tests__/ReactDOMProduction-test.js b/src/renderers/dom/__tests__/ReactDOMProduction-test.js new file mode 100644 index 0000000000..997958caf8 --- /dev/null +++ b/src/renderers/dom/__tests__/ReactDOMProduction-test.js @@ -0,0 +1,90 @@ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @emails react-core + */ + +'use strict'; + +describe('ReactDOMProduction', function() { + var oldProcess; + + var React; + var ReactDOM; + + beforeEach(function() { + __DEV__ = true; + oldProcess = process; + global.process = {env: {NODE_ENV: 'production'}}; + + require('mock-modules').dumpCache(); + React = require('React'); + ReactDOM = require('ReactDOM'); + }); + + afterEach(function() { + __DEV__ = false; + global.process = oldProcess; + }); + + it('should use prod fbjs', function() { + var warning = require('warning'); + + spyOn(console, 'error'); + warning(false, 'Do cows go moo?'); + expect(console.error.argsForCall.length).toBe(0); + }); + + it('should use prod React', function() { + spyOn(console, 'error'); + + // no key warning + void
{[]}
; + + expect(console.error.argsForCall.length).toBe(0); + }); + + it('should handle a simple flow', function() { + var Component = React.createClass({ + render: function() { + return {this.props.children}; + }, + }); + + var container = document.createElement('div'); + var inst = ReactDOM.render( +
+ A + B + C +
, + container + ); + + expect(container.firstChild).toBe(inst); + expect(inst.className).toBe('blue'); + expect(inst.textContent).toBe('ABC'); + + ReactDOM.render( +
+ B + A + C +
, + container + ); + + expect(inst.className).toBe('red'); + expect(inst.textContent).toBe('BAC'); + + ReactDOM.unmountComponentAtNode(container); + + expect(container.childNodes.length).toBe(0); + }); + +});