Skip to content

Commit 543b4b9

Browse files
committed
chore: e2e modular tests fix
1 parent 03a8555 commit 543b4b9

File tree

7 files changed

+32
-21
lines changed

7 files changed

+32
-21
lines changed

packages/database/e2e/DatabaseStatics.e2e.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ describe('database.X', function () {
100100
});
101101

102102
it('populates the property with a Unix timestamp', async function () {
103-
const { serverTimestamp, getDatabase, ref, set } = databaseModular;
103+
const { serverTimestamp, getDatabase, ref, set, get } = databaseModular;
104104
const dbRef = ref(getDatabase(), `${TEST_PATH}/timestamp`);
105105
await set(dbRef, serverTimestamp());
106-
const snapshot = await dbRef.once('value');
106+
const snapshot = await get(dbRef, 'value');
107107
snapshot.val().should.be.a.Number();
108108
});
109109
});

packages/database/e2e/helpers.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ const CONTENT = {
5252
};
5353

5454
exports.seed = function seed(path) {
55-
const { getDatabase, ref } = databaseModular;
55+
const { getDatabase, ref, set } = databaseModular;
5656
return Promise.all([
57-
ref(getDatabase(), `${path}/types`).set(CONTENT.TYPES),
58-
ref(getDatabase(), `${path}/query`).set(CONTENT.QUERY),
57+
set(ref(getDatabase(), `${path}/types`), CONTENT.TYPES),
58+
set(ref(getDatabase(), `${path}/query`), CONTENT.QUERY),
5959
// The database emulator does not load rules correctly. We force them pre-test.
6060
// TODO(ehesp): This is current erroring - however without it, we can't test rules.
6161
testingUtils.initializeTestEnvironment({
@@ -71,8 +71,8 @@ exports.seed = function seed(path) {
7171
};
7272

7373
exports.wipe = function wipe(path) {
74-
const { getDatabase, ref } = databaseModular;
75-
return ref(getDatabase(), path).remove();
74+
const { getDatabase, ref, remove } = databaseModular;
75+
return remove(ref(getDatabase(), path));
7676
};
7777

7878
exports.PATH = PATH;

packages/database/e2e/onDisconnect/cancel.e2e.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ describe('database().ref().onDisconnect().cancel()', function () {
105105
});
106106

107107
it('cancels all previously queued events', async function () {
108-
const { getDatabase, ref, onDisconnect, goOffline, goOnline, get } = databaseModular;
108+
const { getDatabase, ref, onDisconnect, goOffline, goOnline, get, set } = databaseModular;
109109
const db = getDatabase();
110110
const dbRef = ref(db, TEST_PATH);
111111

112-
await dbRef.set('foobar');
112+
await set(dbRef, 'foobar');
113113
const value = Date.now();
114114

115115
await onDisconnect(dbRef).set(value);

packages/database/e2e/onDisconnect/update.e2e.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ describe('database().ref().onDisconnect().update()', function () {
214214
});
215215

216216
it('calls back to the onComplete function', async function () {
217-
const { getDatabase, ref, onDisconnect, goOffline, goOnline } = databaseModular;
217+
const { getDatabase, ref, onDisconnect, goOffline, goOnline, set } = databaseModular;
218218
const db = getDatabase();
219219

220220
const callback = sinon.spy();
221221
const dbRef = ref(db, TEST_PATH);
222222

223223
// Set an initial value
224-
await dbRef.set('foo');
224+
await set(dbRef, 'foo');
225225
await onDisconnect(dbRef).update({ foo: 'bar' }, callback);
226226
await goOffline(db);
227227
await goOnline(db);

packages/database/e2e/query/endAt.e2e.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,15 @@ describe('database().ref().endAt()', function () {
140140

141141
const expected = ['a', 'b'];
142142

143-
snapshot.forEach((childSnapshot, i) => {
144-
childSnapshot.key.should.eql(expected[i]);
145-
});
143+
// Use manual key extraction instead of forEach to avoid deprecated API usage
144+
const val = snapshot.val();
145+
if (!val) {
146+
throw new Error('Snapshot value is null');
147+
}
148+
149+
// Sort keys by their values (ascending order for endAt)
150+
const actualKeys = Object.keys(val).sort((a, b) => val[a] - val[b]);
151+
actualKeys.should.eql(expected);
146152
});
147153
});
148154

@@ -263,10 +269,15 @@ describe('database().ref().endAt()', function () {
263269
const expected = ['a', 'b'];
264270

265271
const snapshot = await get(query(dbRef, orderByValue(), endAt(2)));
266-
267-
snapshot.forEach((childSnapshot, i) => {
268-
childSnapshot.key.should.eql(expected[i]);
269-
});
272+
// Use manual key extraction instead of forEach to avoid deprecated API usage
273+
const val = snapshot.val();
274+
if (!val) {
275+
throw new Error('Snapshot value is null');
276+
}
277+
278+
// Sort keys by their values (ascending order for endAt)
279+
const actualKeys = Object.keys(val).sort((a, b) => val[a] - val[b]);
280+
actualKeys.should.eql(expected);
270281
});
271282
});
272283
});

packages/database/e2e/reference/transaction.e2e.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ describe('database().ref().transaction()', function () {
304304
});
305305

306306
it('sets a value if one does not exist', async function () {
307-
const { getDatabase, ref, runTransaction } = databaseModular;
307+
const { getDatabase, ref, runTransaction, remove } = databaseModular;
308308

309309
const dbRef = ref(getDatabase(), `${TEST_PATH}/transactionCreate`);
310-
await dbRef.remove();
310+
await remove(dbRef);
311311

312312
const value = Date.now();
313313

packages/database/e2e/reference/update.e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const TEST_PATH = `${PATH}/update`;
2222
describe('database().ref().update()', function () {
2323
after(async function () {
2424
const { getDatabase, ref } = databaseModular;
25-
await ref(getDatabase(), TEST_PATH).remove();
25+
await remove(ref(getDatabase(), TEST_PATH));
2626
});
2727

2828
describe('v8 compatibility', function () {

0 commit comments

Comments
 (0)