Skip to content

Commit 852cd5b

Browse files
David BjerremoseDavid Bjerremose
David Bjerremose
authored and
David Bjerremose
committed
Added basic test case for ability to run as function
1 parent 5f52e88 commit 852cd5b

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

Diff for: tests/vuefire.spec.js

+33-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ var firebaseApp = Firebase.initializeApp({
1212

1313
describe('VueFire', function () {
1414
var firebaseRef
15+
var firebaseDb
1516

1617
beforeEach(function (done) {
17-
firebaseRef = firebaseApp.database().ref()
18+
firebaseDb = firebaseApp.database()
19+
firebaseRef = firebaseDb.ref()
1820
firebaseRef.remove(function (error) {
1921
if (error) {
2022
done(error)
@@ -25,6 +27,36 @@ describe('VueFire', function () {
2527
})
2628
})
2729

30+
describe('is callable as Function', function () {
31+
it('returns correct ref on function call', function (done) {
32+
var ChildComponent = Vue.extend({
33+
name: 'ChildComponent',
34+
firebase: function () {
35+
expect(this.$root.database).to.deep.equal(firebaseDb)
36+
done()
37+
},
38+
template: '<div>test</div>'
39+
})
40+
new Vue({
41+
data: function () {
42+
return {
43+
database: firebaseDb
44+
}
45+
},
46+
ready: function () {
47+
expect('poop').to.equal('notpoop')
48+
},
49+
components: {
50+
'child-component': ChildComponent
51+
},
52+
template: '<div><child-component></child-component></div>'
53+
}).$mount()
54+
Vue.nextTick(function () {
55+
56+
})
57+
})
58+
})
59+
2860
describe('bind as Array', function () {
2961
it('throws error for invalid firebase ref', function () {
3062
helpers.invalidFirebaseRefs.forEach(function (ref) {

0 commit comments

Comments
 (0)