[tests][database] added 'child_added' test for issue #221 - thanks @TiraO
This commit is contained in:
parent
2f67e8b35b
commit
9cd4641f06
@ -98,7 +98,7 @@ PODS:
|
|||||||
- React/cxxreact (0.44.3):
|
- React/cxxreact (0.44.3):
|
||||||
- React/jschelpers
|
- React/jschelpers
|
||||||
- React/jschelpers (0.44.3)
|
- React/jschelpers (0.44.3)
|
||||||
- RNFirebase (1.1.2)
|
- RNFirebase (2.0.0)
|
||||||
- Yoga (0.44.3.React)
|
- Yoga (0.44.3.React)
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
@ -143,7 +143,7 @@ SPEC CHECKSUMS:
|
|||||||
GTMSessionFetcher: 30d874b96d0d76028f61fbd122801e3f030d47db
|
GTMSessionFetcher: 30d874b96d0d76028f61fbd122801e3f030d47db
|
||||||
Protobuf: d582fecf68201eac3d79ed61369ef45734394b9c
|
Protobuf: d582fecf68201eac3d79ed61369ef45734394b9c
|
||||||
React: 6361345ebeb769a929e10a06baf0c868d6d03ad5
|
React: 6361345ebeb769a929e10a06baf0c868d6d03ad5
|
||||||
RNFirebase: 7310b8755cc32583f62f11e61b28f839046de5eb
|
RNFirebase: dcc4dcb1c9400a9bc01866e50d1351272a7df311
|
||||||
Yoga: c90474ca3ec1edba44c97b6c381f03e222a9e287
|
Yoga: c90474ca3ec1edba44c97b6c381f03e222a9e287
|
||||||
|
|
||||||
PODFILE CHECKSUM: 45666f734ebfc8b3b0f2be0a83bc2680caeb502f
|
PODFILE CHECKSUM: 45666f734ebfc8b3b0f2be0a83bc2680caeb502f
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import onTests from './on/onTests';
|
import onTests from './on/onTests';
|
||||||
import onValueTests from './on/onValueTests';
|
import onValueTests from './on/onValueTests';
|
||||||
|
import onChildAddedTests from './on/onChildAddedTests';
|
||||||
import offTests from './offTests';
|
import offTests from './offTests';
|
||||||
import onceTests from './onceTests';
|
import onceTests from './onceTests';
|
||||||
import setTests from './setTests';
|
import setTests from './setTests';
|
||||||
@ -21,7 +22,7 @@ import DatabaseContents from '../../support/DatabaseContents';
|
|||||||
|
|
||||||
const testGroups = [
|
const testGroups = [
|
||||||
issueSpecificTests, factoryTests, keyTests, parentTests, childTests, rootTests,
|
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,
|
removeTests, setTests, transactionTests, queryTests, refTests, isEqualTests,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
36
tests/src/tests/database/ref/on/onChildAddedTests.js
Normal file
36
tests/src/tests/database/ref/on/onChildAddedTests.js
Normal 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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -1,12 +1,10 @@
|
|||||||
function refTests({ describe, it, firebase }) {
|
function refTests({ describe, it, firebase }) {
|
||||||
describe('ref().ref', () => {
|
describe('ref().ref', () => {
|
||||||
it('returns a the reference itself', () => {
|
it('returns the reference', () => {
|
||||||
// Setup
|
// Setup
|
||||||
|
|
||||||
const ref = firebase.native.database().ref();
|
const ref = firebase.native.database().ref();
|
||||||
|
|
||||||
// Assertion
|
// Assertion
|
||||||
|
|
||||||
ref.ref.should.eql(ref);
|
ref.ref.should.eql(ref);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user