def test_can_bundle_a_jsx_component(self): bundle = bundle_component(Components.HELLO_WORLD_JSX, translate=True) asset = bundle.get_assets()[0] self.assertTrue(os.path.exists(asset['path'])) with open(asset['path'], 'r') as asset_file: contents = asset_file.read() self.assertIn('// __WEBPACK_TRANSLATE_BUNDLE_TEST__', contents)
def test_can_pass_props_when_rendering_a_bundled_jsx_component(self): bundle = bundle_component(Components.HELLO_WORLD_JSX, translate=True) asset = bundle.get_assets()[0] component = render_component(asset['path'], props={'name': 'world!'}, to_static_markup=True) self.assertEqual(str(component), '<span>Hello world!</span>')
def test_can_pass_props_when_rendering_a_bundled_jsx_component(self): bundle = bundle_component(Components.HELLO_WORLD_JSX, translate=True) asset = bundle.get_assets()[0] component = render_component(asset['path'], props={'name': 'world!'}, to_static_markup=True) self.assertEqual( str(component), '<span>Hello world!</span>' )
def test_bundled_components_omit_react_and_react_addons(self): bundle = bundle_component(Components.REACT_ADDONS, translate=True) with open(bundle.get_assets()[0]['path'], 'r') as bundle_file: content = bundle_file.read() # A bit hacky, but seems to work self.assertNotIn('Facebook', content)
def test_can_render_a_bundled_jsx_component(self): bundle = bundle_component(Components.HELLO_WORLD_JSX, translate=True) asset = bundle.get_assets()[0] component = render_component(asset['path'], to_static_markup=True) self.assertEqual(str(component), '<span>Hello </span>')