Skip to content

Commit e3102af

Browse files
authored
Version v1.3.4 (prescottprue#96)
### Enhancements * prescottprue#92, prescottprue#94 - Issue with query params containing numbers (thanks @biomorgoth) * prescottprue#82, prescottprue#83 - dispatch parameter fixed in `unWatchEvent` * prescottprue#89 - Separate sections added to docs for [`props.firebase`](http://react-redux-firebase.com/docs/api/props-firebase.html) and [`getFirebase`](http://react-redux-firebase.com/docs/api/get-firebase.html)
1 parent ca49464 commit e3102af

File tree

4 files changed

+122
-9
lines changed

4 files changed

+122
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-firebase",
3-
"version": "1.3.3",
3+
"version": "1.3.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",

tests/unit/helpers.spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,6 @@ describe('Helpers:', () => {
282282
{ child: 'collaborators', root: rootName },
283283
]
284284
// TODO: Test both children are populated
285-
console.log('--------3', helpers.populatedDataToJS(exampleState, path, populates))
286-
console.log('should have', exampleData.data[rootName])
287285
expect(helpers.populatedDataToJS(exampleState, `/${path}`, populates))
288286
.to
289287
.have

tests/unit/utils/actions.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
const method = () => Promise.resolve()
66
const failMethod = () => Promise.reject()
77
const dispatch = () => {
8-
console.log('dispatch called')
8+
// console.log('dispatch called')
99
}
1010
describe('Utils: Auth', () => {
1111
describe('wrapInDispatch', () => {

tests/unit/utils/query.spec.js

Lines changed: 120 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,47 @@ import {
77
getQueryIdFromPath,
88
applyParamsToQuery
99
} from '../../../src/utils/query'
10+
const fakeFirebase = {
11+
_: {
12+
authUid: '123',
13+
config: {
14+
userProfile: 'users',
15+
disableRedirectHandling: true,
16+
},
17+
},
18+
database: () => ({
19+
ref: () => ({
20+
orderByValue: () => ({
21+
on: () => ({ val: () => { some: 'obj' } }),
22+
off: () => Promise.resolve({ val: () => { some: 'obj' }}),
23+
once: () => Promise.resolve({ val: () => { some: 'obj' }})
24+
}),
25+
orderByPriority: () => ({
26+
startAt: (startParam) => startParam,
27+
toString: () => 'priority'
28+
}),
29+
orderByChild: (child) => ({
30+
equalTo: (equalTo) => ({
31+
child,
32+
equalTo
33+
}),
34+
toString: () => child
35+
}),
36+
orderByKey: () => ({ }),
37+
limitToFirst: () => ({ }),
38+
limitToLast: () => ({ }),
39+
equalTo: () => ({ }),
40+
startAt: () => ({ }),
41+
endAt: () => ({ }),
42+
})
43+
}),
44+
}
45+
let spy
46+
1047
let createQueryFromParams = (queryParams) =>
11-
applyParamsToQuery(queryParams, Firebase.database().ref())
48+
applyParamsToQuery(queryParams, fakeFirebase.database().ref())
1249
const dispatch = () => {}
50+
let ref
1351
describe('Utils: Query', () => {
1452
describe('getWatchPath', () => {
1553
it('handles basic path', () => {
@@ -78,15 +116,92 @@ describe('Utils: Query', () => {
78116
it('orderByValue', () => {
79117
expect(createQueryFromParams(['orderByValue=uid'])).to.be.an.object
80118
})
81-
it('orderByPriority', () => {
82-
expect(createQueryFromParams(['orderByPriority=uid'])).to.be.an.object
119+
120+
describe('orderByPriority', () => {
121+
it('handles single parameter', () => {
122+
expect(createQueryFromParams(['orderByPriority']).toString())
123+
.to.equal('priority')
124+
})
125+
126+
describe('with startAt', () => {
127+
it ('string containing number', () => {
128+
const startAt = '123abc'
129+
expect(createQueryFromParams(['orderByPriority', `startAt=${startAt}`]).toString())
130+
.to.equal(startAt)
131+
})
132+
})
83133
})
134+
84135
it('orderByKey', () => {
85136
expect(createQueryFromParams(['orderByKey'])).to.be.an.object
86137
})
87-
it('orderByChild', () => {
88-
expect(createQueryFromParams(['orderByChild=uid'])).to.be.an.object
138+
139+
describe('orderByChild', () => {
140+
it('handles single parameter', () => {
141+
const queryParams = createQueryFromParams(['orderByChild=uid'])
142+
expect(queryParams.toString()).to.equal('uid')
143+
})
144+
145+
describe('with equalTo', () => {
146+
it('number', () => {
147+
const child = 'emailAddress'
148+
const equalTo = 1
149+
const queryParams = createQueryFromParams([`orderByChild=${child}`, `equalTo=${equalTo}`])
150+
expect(queryParams.child)
151+
.to
152+
.equal(child)
153+
expect(queryParams.equalTo)
154+
.to
155+
.equal(equalTo)
156+
})
157+
it('boolean', () => {
158+
const child = 'completed'
159+
const equalTo = false
160+
const queryParams = createQueryFromParams([`orderByChild=${child}`, `equalTo=${equalTo}`])
161+
expect(queryParams.child)
162+
.to
163+
.equal(child)
164+
expect(queryParams.equalTo)
165+
.to
166+
.equal(equalTo)
167+
})
168+
it('string containing a boolean', () => {
169+
const child = 'emailAddress'
170+
const equalTo = 'true'
171+
const queryParams = createQueryFromParams([`orderByChild=${child}`, `equalTo=${equalTo}`])
172+
expect(queryParams.child)
173+
.to
174+
.equal(child)
175+
expect(queryParams.equalTo)
176+
.to
177+
.equal(true)
178+
})
179+
it('string containing null', () => {
180+
const child = 'emailAddress'
181+
const equalTo = 'null'
182+
const queryParams = createQueryFromParams([`orderByChild=${child}`, `equalTo=${equalTo}`])
183+
expect(queryParams.child)
184+
.to
185+
.equal(child)
186+
expect(queryParams.equalTo)
187+
.to
188+
.equal(null)
189+
})
190+
it('string containing a number', () => {
191+
const child = 'emailAddress'
192+
const equalTo = '[email protected]'
193+
const queryParams = createQueryFromParams([`orderByChild=${child}`, `equalTo=${equalTo}`])
194+
expect(queryParams.child)
195+
.to
196+
.equal(child)
197+
expect(queryParams.equalTo)
198+
.to
199+
.equal(equalTo)
200+
})
201+
})
202+
89203
})
204+
90205
it('limitToFirst', () => {
91206
expect(createQueryFromParams(['limitToFirst=1'])).to.be.an.object
92207
})

0 commit comments

Comments
 (0)