Skip to content

Instantly share code, notes, and snippets.

@ivawzh
Last active July 12, 2016 16:40
Show Gist options
  • Save ivawzh/0c1273ddc134e37f7b96cc7cc9b15e2f to your computer and use it in GitHub Desktop.
Save ivawzh/0c1273ddc134e37f7b96cc7cc9b15e2f to your computer and use it in GitHub Desktop.
Spec for firebase-faker test helper
import { expect } from 'chai'
import { setupDatabase, destroyDatabase } from './firebase-faker'
describe('Firebase fake server', () => {
let server, data, client
beforeEach(() => {
const port = 45001
data = {
states: {
CA: 'California',
AL: 'Alabama',
KY: 'Kentucky'
}
};
({ server, client } = setupDatabase(port, data))
})
afterEach(() => {
destroyDatabase(server, client)
})
describe('supports .once value', () => {
it('gives data', async done => {
const snap = await client.ref('states/CA').once('value')
expect(snap.val()).to.eq('California')
done()
})
it('gives all data', async done => {
const snap = await client.ref().once('value')
expect(snap.val()).to.eql(data)
done()
})
})
describe('supports .set', () => {
it('write input into node', async done => {
await client.ref().set('input')
const newData = await server.getValue()
expect(newData).to.eq('input')
done()
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment