Skip to content

Commit 2685cde

Browse files
Update test
1 parent 14bf2d8 commit 2685cde

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/database/test/transaction.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
} from './helpers/util';
3535

3636
import '../index';
37+
import { Deferred } from '@firebase/util';
3738

3839
describe('Transaction Tests', () => {
3940
// Tests that use hijackHash() should set restoreHash to the restore function
@@ -561,6 +562,8 @@ describe('Transaction Tests', () => {
561562

562563
await node.child('foo').set(5);
563564

565+
const deferred = new Deferred<void>();
566+
564567
// 'foo' gets overwritten in the update so the transaction gets cancelled.
565568
node.child('foo').transaction(
566569
old => {
@@ -569,7 +572,7 @@ describe('Transaction Tests', () => {
569572
(error, committed, snapshot) => {
570573
expect(error.message).to.equal('set');
571574
expect(committed).to.equal(false);
572-
fooTransactionDone = true;
575+
deferred.resolve();
573576
}
574577
);
575578

@@ -595,7 +598,7 @@ describe('Transaction Tests', () => {
595598
}
596599
});
597600

598-
expect(fooTransactionDone).to.equal(true);
601+
await deferred.promise;
599602
expect(barTransactionDone).to.equal(false);
600603
restoreHash();
601604
restoreHash = null;

0 commit comments

Comments
 (0)