This commit is contained in:
Salakar
2017-07-20 09:59:52 +01:00
15 changed files with 409 additions and 221 deletions

View File

@@ -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) {

View 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;