mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-29 12:45:45 +08:00
added test for issue #100
This commit is contained in:
@@ -15,11 +15,12 @@ import refTests from './refTests';
|
|||||||
import rootTests from './rootTests';
|
import rootTests from './rootTests';
|
||||||
import transactionTests from './transactionTests';
|
import transactionTests from './transactionTests';
|
||||||
import queryTests from './queryTests';
|
import queryTests from './queryTests';
|
||||||
|
import issueSpecificTests from './issueSpecificTests';
|
||||||
|
|
||||||
import DatabaseContents from '../../support/DatabaseContents';
|
import DatabaseContents from '../../support/DatabaseContents';
|
||||||
|
|
||||||
const testGroups = [
|
const testGroups = [
|
||||||
factoryTests, keyTests, parentTests, childTests, rootTests,
|
issueSpecificTests, factoryTests, keyTests, parentTests, childTests, rootTests,
|
||||||
pushTests, onTests, onValueTests, offTests, onceTests, updateTests,
|
pushTests, onTests, onValueTests, offTests, onceTests, updateTests,
|
||||||
removeTests, setTests, transactionTests, queryTests, refTests, isEqualTests,
|
removeTests, setTests, transactionTests, queryTests, refTests, isEqualTests,
|
||||||
];
|
];
|
||||||
@@ -29,10 +30,12 @@ function registerTestSuite(testSuite) {
|
|||||||
this._databaseRef = testSuite.firebase.native.database().ref('tests/types');
|
this._databaseRef = testSuite.firebase.native.database().ref('tests/types');
|
||||||
|
|
||||||
await this._databaseRef.set(DatabaseContents.DEFAULT);
|
await this._databaseRef.set(DatabaseContents.DEFAULT);
|
||||||
|
await this._databaseRef.parent.child('issues').set(DatabaseContents.ISSUES);
|
||||||
});
|
});
|
||||||
|
|
||||||
testSuite.afterEach(async function () {
|
testSuite.afterEach(async function () {
|
||||||
await this._databaseRef.set(DatabaseContents.DEFAULT);
|
await this._databaseRef.set(DatabaseContents.DEFAULT);
|
||||||
|
await this._databaseRef.parent.child('issues').set(DatabaseContents.ISSUES);
|
||||||
});
|
});
|
||||||
|
|
||||||
testGroups.forEach((testGroup) => {
|
testGroups.forEach((testGroup) => {
|
||||||
|
|||||||
24
tests/src/tests/database/ref/issueSpecificTests.js
Normal file
24
tests/src/tests/database/ref/issueSpecificTests.js
Normal 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;
|
||||||
@@ -15,11 +15,11 @@ import DatabaseContents from '../../../support/DatabaseContents';
|
|||||||
*/
|
*/
|
||||||
const DATATYPES_WITH_DUPLICATE_CALLBACK_CALLS = [
|
const DATATYPES_WITH_DUPLICATE_CALLBACK_CALLS = [
|
||||||
'array',
|
'array',
|
||||||
'number'
|
'number',
|
||||||
];
|
];
|
||||||
|
|
||||||
function onTests({ fdescribe, context, it, firebase, tryCatch }) {
|
function onTests({ describe, context, it, firebase, tryCatch }) {
|
||||||
fdescribe('ref().on(\'value\')', () => {
|
describe('ref().on(\'value\')', () => {
|
||||||
// Documented Web API Behaviour
|
// Documented Web API Behaviour
|
||||||
it('returns the success callback', () => {
|
it('returns the success callback', () => {
|
||||||
// Setup
|
// Setup
|
||||||
|
|||||||
@@ -22,4 +22,22 @@ export default {
|
|||||||
foo: 'baz',
|
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',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user