Skip to content

Commit

Permalink
fix(database): remove duplicate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 committed Sep 19, 2023
1 parent dacdb4c commit 9eef408
Show file tree
Hide file tree
Showing 76 changed files with 4,004 additions and 6,982 deletions.
115 changes: 86 additions & 29 deletions packages/database/e2e/DatabaseStatics.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,105 @@ const { PATH, wipe } = require('./helpers');
const TEST_PATH = `${PATH}/statics`;

describe('database.X', function () {
after(function () {
return wipe(TEST_PATH);
});
describe('v8 compatibility', function () {
after(function () {
return wipe(TEST_PATH);
});

describe('ServerValue.TIMESTAMP', function () {
it('returns a valid object', function () {
const { TIMESTAMP } = firebase.database.ServerValue;
should.equal(Object.keys(TIMESTAMP).length, 1);
TIMESTAMP.should.have.property('.sv');
TIMESTAMP['.sv'].should.eql('timestamp');
});
});

describe('ServerValue.increment', function () {
it('returns a valid object', function () {
const incrementObject = firebase.database.ServerValue.increment(1);
should.equal(Object.keys(incrementObject).length, 1);
incrementObject.should.have.property('.sv');
incrementObject['.sv'].should.have.property('increment');
});

it('increments on the server', async function () {
const ref = firebase.database().ref(`${TEST_PATH}/increment`);

await ref.set({ increment: 0 });

const res1 = await ref.once('value');
res1.val().increment.should.equal(0);

await ref.set({ increment: firebase.database.ServerValue.increment(1) });

const res2 = await ref.once('value');
res2.val().increment.should.equal(1);
});

describe('ServerValue.TIMESTAMP', function () {
it('returns a valid object', function () {
const { TIMESTAMP } = firebase.database.ServerValue;
should.equal(Object.keys(TIMESTAMP).length, 1);
TIMESTAMP.should.have.property('.sv');
TIMESTAMP['.sv'].should.eql('timestamp');
it('increments on the server when no value is present', async function () {
const ref = firebase.database().ref(`${TEST_PATH}/increment-empty`);

await ref.set({ increment: firebase.database.ServerValue.increment(2) });

const res = await ref.once('value');
res.val().increment.should.equal(2);
});
});
});

describe('ServerValue.increment', function () {
it('returns a valid object', function () {
const incrementObject = firebase.database.ServerValue.increment(1);
should.equal(Object.keys(incrementObject).length, 1);
incrementObject.should.have.property('.sv');
incrementObject['.sv'].should.have.property('increment');
describe('modular', function () {
after(function () {
return wipe(TEST_PATH);
});

it('increments on the server', async function () {
const ref = firebase.database().ref(`${TEST_PATH}/increment`);
describe('serverTimestamp', function () {
it('returns a valid object', function () {
const { serverTimestamp } = databaseModular;
const timestamp = serverTimestamp();

await ref.set({ increment: 0 });
should.equal(Object.keys(timestamp).length, 1);
timestamp.should.have.property('.sv');
timestamp['.sv'].should.eql('timestamp');
});
});

const res1 = await ref.once('value');
res1.val().increment.should.equal(0);
describe('increment', function () {
it('returns a valid object', function () {
const { increment } = databaseModular;

await ref.set({ increment: firebase.database.ServerValue.increment(1) });
const incrementObject = increment(1);
should.equal(Object.keys(incrementObject).length, 1);
incrementObject.should.have.property('.sv');
incrementObject['.sv'].should.have.property('increment');
});

const res2 = await ref.once('value');
res2.val().increment.should.equal(1);
});
it('increments on the server', async function () {
const { getDatabase, ref, set, get, increment } = databaseModular;

const dbRef = ref(getDatabase(), `${TEST_PATH}/increment`);

await set(dbRef, { increment: 0 });

const res1 = await get(dbRef);
res1.val().increment.should.equal(0);

await set(dbRef, { increment: increment(1) });

const res2 = await get(dbRef);
res2.val().increment.should.equal(1);
});

it('increments on the server when no value is present', async function () {
const { getDatabase, ref, set, get, increment } = databaseModular;

it('increments on the server when no value is present', async function () {
const ref = firebase.database().ref(`${TEST_PATH}/increment-empty`);
const dbRef = ref(getDatabase(), `${TEST_PATH}/increment-empty`);

await ref.set({ increment: firebase.database.ServerValue.increment(2) });
await set(dbRef, { increment: increment(2) });

const res = await ref.once('value');
res.val().increment.should.equal(2);
const res = await get(dbRef);
res.val().increment.should.equal(2);
});
});
});
});
124 changes: 0 additions & 124 deletions packages/database/e2e/DatabaseStatics.modular.e2e.js

This file was deleted.

Loading

0 comments on commit 9eef408

Please sign in to comment.