2
0
mirror of synced 2025-02-02 17:43:27 +00:00

[tests][database] added 'child_added' test for issue #221 - thanks @TiraO

This commit is contained in:
Salakar 2017-07-04 16:19:41 +01:00
parent 2f67e8b35b
commit 9cd4641f06
4 changed files with 41 additions and 6 deletions

View File

@ -98,7 +98,7 @@ PODS:
- React/cxxreact (0.44.3):
- React/jschelpers
- React/jschelpers (0.44.3)
- RNFirebase (1.1.2)
- RNFirebase (2.0.0)
- Yoga (0.44.3.React)
DEPENDENCIES:
@ -143,7 +143,7 @@ SPEC CHECKSUMS:
GTMSessionFetcher: 30d874b96d0d76028f61fbd122801e3f030d47db
Protobuf: d582fecf68201eac3d79ed61369ef45734394b9c
React: 6361345ebeb769a929e10a06baf0c868d6d03ad5
RNFirebase: 7310b8755cc32583f62f11e61b28f839046de5eb
RNFirebase: dcc4dcb1c9400a9bc01866e50d1351272a7df311
Yoga: c90474ca3ec1edba44c97b6c381f03e222a9e287
PODFILE CHECKSUM: 45666f734ebfc8b3b0f2be0a83bc2680caeb502f

View File

@ -1,5 +1,6 @@
import onTests from './on/onTests';
import onValueTests from './on/onValueTests';
import onChildAddedTests from './on/onChildAddedTests';
import offTests from './offTests';
import onceTests from './onceTests';
import setTests from './setTests';
@ -21,7 +22,7 @@ import DatabaseContents from '../../support/DatabaseContents';
const testGroups = [
issueSpecificTests, factoryTests, keyTests, parentTests, childTests, rootTests,
pushTests, onTests, onValueTests, offTests, onceTests, updateTests,
pushTests, onTests, onValueTests, onChildAddedTests, offTests, onceTests, updateTests,
removeTests, setTests, transactionTests, queryTests, refTests, isEqualTests,
];

View File

@ -0,0 +1,36 @@
import 'should-sinon';
import Promise from 'bluebird';
export default function onChildAddedTests({ describe, beforeEach, afterEach, it, firebase }) {
describe('ref().on(\'child_added\')', () => {
describe('the snapshot', () => {
let ref;
let childRef;
let childVal;
beforeEach(async () => {
ref = firebase.native.database().ref('tests/types/object');
await new Promise((resolve) => {
ref.on('child_added', (snapshot) => {
childRef = snapshot.ref;
childVal = snapshot.val();
resolve();
});
});
});
afterEach(() => {
ref.off();
});
// https://github.com/invertase/react-native-firebase/issues/221
it('has a key that identifies the child', () => {
(childRef.key).should.equal('foo');
});
it('has the value of the child', () => {
(childVal).should.equal('bar');
});
});
});
}

View File

@ -1,12 +1,10 @@
function refTests({ describe, it, firebase }) {
describe('ref().ref', () => {
it('returns a the reference itself', () => {
it('returns the reference', () => {
// Setup
const ref = firebase.native.database().ref();
// Assertion
ref.ref.should.eql(ref);
});
});