Skip to content

Commit 17a9b99

Browse files
authored
Version 1.4.4 (#189)
* Adds two statics to a connected component: * `wrappedComponent`, which is the original component (useful for testing without mocking firebase) * `displayName` is set to reveal what component is wrapped by FirebaseConnect. This makes debugging easier * Tests added for both new statics listed above * Remove open collective as a dependency (not used in `postinstall`)
1 parent 7ac2b19 commit 17a9b99

File tree

4 files changed

+230
-5
lines changed

4 files changed

+230
-5
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-firebase",
3-
"version": "1.4.3",
3+
"version": "1.4.4",
44
"description": "Redux integration for Firebase. Comes with a Higher Order Component for use with React.",
55
"browser": "dist/react-redux-firebase.js",
66
"main": "lib/index.js",
@@ -36,7 +36,7 @@
3636
"immutable": "^3.8.1",
3737
"jwt-decode": "^2.2.0",
3838
"lodash": "^4.17.4",
39-
"opencollective": "^1.0.3"
39+
"react-display-name": "^0.2.0"
4040
},
4141
"peerDependencies": {
4242
"react": "^0.14.6 || ^15.0.0"

src/connect.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component, PropTypes } from 'react'
2+
import getDisplayName from 'react-display-name'
23
import { isEqual } from 'lodash'
34
import hoistStatics from 'hoist-non-react-statics'
45
import { watchEvents, unWatchEvents } from './actions/query'
@@ -56,7 +57,11 @@ export default (dataOrFn = []) => WrappedComponent => {
5657

5758
static contextTypes = {
5859
store: PropTypes.object.isRequired
59-
};
60+
}
61+
62+
static displayName = `FirebaseConnect(${getDisplayName(WrappedComponent)}`
63+
64+
static wrappedComponent = WrappedComponent
6065

6166
componentWillMount () {
6267
const { firebase, dispatch } = this.context.store

tests/unit/connect.spec.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React, { createClass, Children, Component, PropTypes } from 'react'
22
import ReactDOM from 'react-dom'
3-
import connect from '../../src/connect'
3+
import firebaseConnect from '../../src/connect'
44
import reactReduxFirebase from '../../src/compose'
55
import TestUtils from 'react-addons-test-utils'
66
import { createStore, compose, combineReducers } from 'redux'
7+
import getDisplayName from 'react-display-name'
78

89
describe('Connect', () => {
910
class Passthrough extends Component {
@@ -40,7 +41,7 @@ describe('Connect', () => {
4041
)(createStore)
4142
const store = createStoreWithMiddleware(combineReducers({ test: (state = {}) => state }))
4243

43-
@connect()
44+
@firebaseConnect()
4445
class Container extends Component {
4546
render() {
4647
return <Passthrough {...this.props} />
@@ -60,4 +61,28 @@ describe('Connect', () => {
6061
expect(container.context.store).to.equal(store)
6162
})
6263

64+
65+
66+
it('sets displayName static as FirebaseConnect${WrappedComponentName}', () => {
67+
class Container extends Component {
68+
render() {
69+
return <Passthrough {...this.props} />
70+
}
71+
}
72+
73+
const containerPrime = firebaseConnect()(Container)
74+
expect(containerPrime.displayName).to.equal(`FirebaseConnect(${getDisplayName(Container)}`)
75+
})
76+
77+
it('sets WrappedComponent static as component which was wrapped', () => {
78+
class Container extends Component {
79+
render() {
80+
return <Passthrough {...this.props} />
81+
}
82+
}
83+
84+
const containerPrime = firebaseConnect()(Container)
85+
expect(containerPrime.wrappedComponent).to.equal(Container)
86+
})
87+
6388
})

0 commit comments

Comments
 (0)