|
| 1 | +/* global describe expect it beforeEach */ |
| 2 | +import { |
| 3 | + watchEvent, |
| 4 | + unWatchEvent, |
| 5 | + watchEvents, |
| 6 | + unWatchEvents |
| 7 | +} from '../../../src/actions/query' |
| 8 | +import Firebase from 'firebase' |
| 9 | +const apiKey = 'AIzaSyCTUERDM-Pchn_UDTsfhVPiwM4TtNIxots' |
| 10 | +const authDomain = 'redux-firebasev3.firebaseapp.com' |
| 11 | +const databaseURL = 'https://redux-firebasev3.firebaseio.com' |
| 12 | +const testFbConfig = { |
| 13 | + databaseURL, |
| 14 | + apiKey, |
| 15 | + authDomain |
| 16 | +} |
| 17 | +let firebase |
| 18 | +describe('query actions', () => { |
| 19 | + describe('watchEvent', () => { |
| 20 | + beforeEach(() => { |
| 21 | + // TODO: Set up a firebase (real for now, fake later) and store (for dispatch) |
| 22 | + // Initialize Firebase |
| 23 | + try { |
| 24 | + Firebase.initializeApp(testFbConfig) |
| 25 | + } catch (err) {} |
| 26 | + |
| 27 | + firebase = Object.defineProperty(Firebase, '_', { |
| 28 | + value: { |
| 29 | + watchers: {}, |
| 30 | + config: testFbConfig, |
| 31 | + authUid: null |
| 32 | + }, |
| 33 | + writable: true, |
| 34 | + enumerable: true, |
| 35 | + configurable: true |
| 36 | + }) |
| 37 | + }) |
| 38 | + it('is exported', () => { |
| 39 | + expect(watchEvent).to.be.a.function |
| 40 | + }) |
| 41 | + it('runs given basic params', () => { |
| 42 | + watchEvent(firebase, () => {}, 'once', 'projects', 'projects') |
| 43 | + }) |
| 44 | + |
| 45 | + describe.skip('populate', () => { |
| 46 | + it('populates id with string', () => { |
| 47 | + // TODO: Confirm that SET action is dispatched with populated data |
| 48 | + }) |
| 49 | + it('populates id with object', () => { |
| 50 | + // TODO: Confirm that SET action is dispatched with populated data |
| 51 | + }) |
| 52 | + it('handles invalid population id', () => { |
| 53 | + // TODO: Confirm that SET action is dispatched with populated data |
| 54 | + }) |
| 55 | + }) |
| 56 | + describe.skip('query types', () => { |
| 57 | + it('once query', () => { |
| 58 | + // TODO: Test that SET action is dispatched with data |
| 59 | + }) |
| 60 | + it('on query', () => { |
| 61 | + // TODO: Confirm that stubbed version of firebase is called |
| 62 | + // TODO: Confirm that SET action is dispatched correctly |
| 63 | + }) |
| 64 | + }) |
| 65 | + describe.skip('filters', () => { |
| 66 | + it('orderByValue', () => { |
| 67 | + |
| 68 | + }) |
| 69 | + it('orderByPriority', () => { |
| 70 | + |
| 71 | + }) |
| 72 | + it('orderByKey', () => { |
| 73 | + |
| 74 | + }) |
| 75 | + it('orderByChild', () => { |
| 76 | + |
| 77 | + }) |
| 78 | + it('limitToFirst', () => { |
| 79 | + |
| 80 | + }) |
| 81 | + it('limitToLast', () => { |
| 82 | + |
| 83 | + }) |
| 84 | + it('equalTo', () => { |
| 85 | + |
| 86 | + }) |
| 87 | + it('startAt', () => { |
| 88 | + |
| 89 | + }) |
| 90 | + it('endAt', () => { |
| 91 | + |
| 92 | + }) |
| 93 | + }) |
| 94 | + }) |
| 95 | + describe('unWatchEvent', () => { |
| 96 | + it('is exported', () => { |
| 97 | + expect(unWatchEvent).to.be.a.function |
| 98 | + }) |
| 99 | + it('runs given basic params', () => { |
| 100 | + unWatchEvent(firebase, () => {}, 'once', 'projects', 'projects') |
| 101 | + }) |
| 102 | + }) |
| 103 | + describe('watchEvents', () => { |
| 104 | + it('is exported', () => { |
| 105 | + expect(watchEvents).to.be.a.function |
| 106 | + }) |
| 107 | + it('runs given basic params', () => { |
| 108 | + watchEvents(firebase, () => {}, [{name: 'once', path: 'test'}]) |
| 109 | + }) |
| 110 | + }) |
| 111 | + describe('unWatchEvents', () => { |
| 112 | + it('is exported', () => { |
| 113 | + expect(unWatchEvents).to.be.a.function |
| 114 | + }) |
| 115 | + it('runs given basic params', () => { |
| 116 | + unWatchEvents(firebase, [{name: 'value', path: 'test'}]) |
| 117 | + }) |
| 118 | + }) |
| 119 | +}) |
0 commit comments