Last active
July 12, 2016 16:40
-
-
Save ivawzh/0c1273ddc134e37f7b96cc7cc9b15e2f to your computer and use it in GitHub Desktop.
Spec for firebase-faker test helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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