Skip to content

Commit

Permalink
Fix build for useCreateElement: false, run Travis
Browse files Browse the repository at this point in the history
It's important that we keep these code paths working because they're the only comprehensive test of adopting server-rendered HTML that we have right now. This is terrible and hacky but I am hopeful that it will at least catch stuff.
  • Loading branch information
sophiebits committed Feb 19, 2016
1 parent 85f2e87 commit 5516677
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ script:
else
./node_modules/.bin/grunt jest:normal
fi
echo 'Testing in server-render (HTML generation) mode...'
echo 'module.exports = {useCreateElement: false};' \
> src/renderers/dom/shared/ReactDOMFeatureFlags.js
./node_modules/.bin/grunt jest:normal
git co -- src/renderers/dom/shared/ReactDOMFeatureFlags.js
else
./node_modules/.bin/grunt $TEST_TYPE
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('ReactDOMInput', function() {
var EventConstants;
var React;
var ReactDOM;
var ReactDOMFeatureFlags;
var ReactLink;
var ReactTestUtils;

Expand All @@ -26,6 +27,7 @@ describe('ReactDOMInput', function() {
EventConstants = require('EventConstants');
React = require('React');
ReactDOM = require('ReactDOM');
ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
ReactLink = require('ReactLink');
ReactTestUtils = require('ReactTestUtils');
spyOn(console, 'error');
Expand Down Expand Up @@ -578,6 +580,9 @@ describe('ReactDOMInput', function() {
});

it('sets type before value always', function() {
if (!ReactDOMFeatureFlags.useCreateElement) {
return;
}
var log = [];
var originalCreateElement = document.createElement;
spyOn(document, 'createElement').andCallFake(function(type) {
Expand Down
8 changes: 7 additions & 1 deletion src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ describe('ReactDOMComponent', function() {
var React;

var ReactDOM;
var ReactDOMFeatureFlags;
var ReactDOMServer;

beforeEach(function() {
jest.resetModuleRegistry();
React = require('React');
ReactDOM = require('ReactDOM');
ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
ReactDOMServer = require('ReactDOMServer');
});

Expand Down Expand Up @@ -294,7 +296,11 @@ describe('ReactDOMComponent', function() {
var container = document.createElement('div');
ReactDOM.render(<svg theWord="theBird" />, container);

expect(container.firstChild.hasAttribute('theWord')).toBe(true);
if (ReactDOMFeatureFlags.useCreateElement) {
// jsdom's svg parsing is a little buggy and makes attributes lowercase,
// only assert this in createElement mode...
expect(container.firstChild.hasAttribute('theWord')).toBe(true);
}
ReactDOM.render(<svg />, container);
expect(container.firstChild.hasAttribute('theWord')).toBe(false);
});
Expand Down

0 comments on commit 5516677

Please sign in to comment.