2
0
mirror of synced 2025-01-11 14:44:12 +00:00

added test for issue #100

This commit is contained in:
Salakar 2017-05-09 16:00:41 +01:00
parent 286f886cfa
commit c8a3440fd4
4 changed files with 49 additions and 4 deletions

View File

@ -15,11 +15,12 @@ import refTests from './refTests';
import rootTests from './rootTests';
import transactionTests from './transactionTests';
import queryTests from './queryTests';
import issueSpecificTests from './issueSpecificTests';
import DatabaseContents from '../../support/DatabaseContents';
const testGroups = [
factoryTests, keyTests, parentTests, childTests, rootTests,
issueSpecificTests, factoryTests, keyTests, parentTests, childTests, rootTests,
pushTests, onTests, onValueTests, offTests, onceTests, updateTests,
removeTests, setTests, transactionTests, queryTests, refTests, isEqualTests,
];
@ -29,10 +30,12 @@ function registerTestSuite(testSuite) {
this._databaseRef = testSuite.firebase.native.database().ref('tests/types');
await this._databaseRef.set(DatabaseContents.DEFAULT);
await this._databaseRef.parent.child('issues').set(DatabaseContents.ISSUES);
});
testSuite.afterEach(async function () {
await this._databaseRef.set(DatabaseContents.DEFAULT);
await this._databaseRef.parent.child('issues').set(DatabaseContents.ISSUES);
});
testGroups.forEach((testGroup) => {

View File

@ -0,0 +1,24 @@
import DatabaseContents from '../../support/DatabaseContents';
function childTests({ fdescribe, it, context, firebase }) {
fdescribe('issue_100', () => {
context('returned snapshot should match web API', () => {
it('returns correct child ref', async () => {
// Setup
const ref = firebase.native.database().ref('tests/issues/100');
// Test
return ref.once('value').then((snapshot) => {
// Assertion
console.warn(JSON.stringify(snapshot.val()));
snapshot.val().should.eql(DatabaseContents.ISSUES[100]);
});
});
});
});
}
export default childTests;

View File

@ -15,11 +15,11 @@ import DatabaseContents from '../../../support/DatabaseContents';
*/
const DATATYPES_WITH_DUPLICATE_CALLBACK_CALLS = [
'array',
'number'
'number',
];
function onTests({ fdescribe, context, it, firebase, tryCatch }) {
fdescribe('ref().on(\'value\')', () => {
function onTests({ describe, context, it, firebase, tryCatch }) {
describe('ref().on(\'value\')', () => {
// Documented Web API Behaviour
it('returns the success callback', () => {
// Setup

View File

@ -22,4 +22,22 @@ export default {
foo: 'baz',
},
},
ISSUES: {
// https://github.com/invertase/react-native-firebase/issues/100
100: {
1: {
someKey: 'someValue',
someOtherKey: 'someOtherValue',
},
2: {
someKey: 'someValue',
someOtherKey: 'someOtherValue',
},
3: {
someKey: 'someValue',
someOtherKey: 'someOtherValue',
},
},
},
};