mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
Merge branch 'master' of https://github.com/invertase/react-native-firebase into multi-apps
This commit is contained in:
@@ -17,6 +17,7 @@ import rootTests from './rootTests';
|
||||
import transactionTests from './transactionTests';
|
||||
import queryTests from './queryTests';
|
||||
import issueSpecificTests from './issueSpecificTests';
|
||||
import priorityTests from './priorityTests';
|
||||
|
||||
import DatabaseContents from '../../support/DatabaseContents';
|
||||
|
||||
@@ -24,6 +25,7 @@ const testGroups = [
|
||||
issueSpecificTests, factoryTests, keyTests, parentTests, childTests, rootTests,
|
||||
pushTests, onTests, onValueTests, onChildAddedTests, offTests, onceTests, updateTests,
|
||||
removeTests, setTests, transactionTests, queryTests, refTests, isEqualTests,
|
||||
priorityTests,
|
||||
];
|
||||
|
||||
function registerTestSuite(testSuite) {
|
||||
|
||||
43
tests/src/tests/database/ref/priorityTests.js
Normal file
43
tests/src/tests/database/ref/priorityTests.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import DatabaseContents from '../../support/DatabaseContents';
|
||||
|
||||
function setTests({ describe, it, firebase }) {
|
||||
describe('ref().priority', () => {
|
||||
it('setPriority() should correctly set a priority for all non-null values', async () => {
|
||||
await Promise.map(Object.keys(DatabaseContents.DEFAULT), async (dataRef) => {
|
||||
// Setup
|
||||
|
||||
const ref = firebase.native.database().ref(`tests/types/${dataRef}`);
|
||||
|
||||
// Test
|
||||
|
||||
await ref.setPriority(1);
|
||||
|
||||
// Assertion
|
||||
|
||||
await ref.once('value').then((snapshot) => {
|
||||
if (snapshot.val() !== null) {
|
||||
snapshot.getPriority().should.eql(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('setWithPriority() should correctly set the priority', async () => {
|
||||
// Setup
|
||||
|
||||
const ref = firebase.native.database().ref('tests/types/number');
|
||||
|
||||
// Test
|
||||
|
||||
await ref.setWithPriority(DatabaseContents.DEFAULT.number, '2');
|
||||
|
||||
// Assertion
|
||||
|
||||
await ref.once('value').then((snapshot) => {
|
||||
snapshot.getPriority().should.eql('2');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default setTests;
|
||||
Reference in New Issue
Block a user