diff --git a/src/__tests__/ReactART-test.js b/src/__tests__/ReactART-test.js index 739c9ed..edfe0b8 100644 --- a/src/__tests__/ReactART-test.js +++ b/src/__tests__/ReactART-test.js @@ -20,6 +20,7 @@ var React = require('react'); var ReactDOM = require('react-dom'); var ReactTestUtils = require('react-addons-test-utils'); +var ClippingRectangle; var Group; var Shape; var Surface; @@ -56,6 +57,7 @@ describe('ReactART', function() { beforeEach(function() { ARTCurrentMode.setCurrent(ARTSVGMode); + ClippingRectangle = ReactART.ClippingRectangle; Group = ReactART.Group; Shape = ReactART.Shape; Surface = ReactART.Surface; @@ -286,4 +288,46 @@ describe('ReactART', function() { expect(ref.constructor).toBe(CustomShape); }); + it('propagates context down through groups', function() { + var contextValue; + var innerExpects = 0; + var CustomShape = React.createClass({ + contextTypes: { + value: React.PropTypes.number + }, + render: function() { + expect(this.context.value).toBe(contextValue); + innerExpects++; + return ; + }, + }); + var Container = React.createClass({ + childContextTypes: { + value: React.PropTypes.number + }, + getChildContext: function() { + return {value: this.props.contextValue}; + }, + render: function() { + return ( + + + + + {this.props.contextValue === 2 && } + + + + ); + }, + }); + + var container = document.createElement('div'); + contextValue = 1; + ReactDOM.render(, container); + contextValue = 2; + ReactDOM.render(, container); + expect(innerExpects).toBe(3); + }); + });