Skip to content

Commit 878fec2

Browse files
committed
Add assertFails test when code is PERMISSION_DENIED
1 parent fd386fe commit 878fec2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/rules-unit-testing/test/database.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,31 @@ describe('Testing Module Tests', function () {
103103
.catch(() => {});
104104
});
105105

106+
it('assertFails() if code is PERMISSION_DENIED', async function () {
107+
const success = Promise.resolve('success');
108+
const permissionDenied = Promise.reject({
109+
code: 'PERMISSION_DENIED'
110+
});
111+
const otherFailure = Promise.reject('failure');
112+
await firebase
113+
.assertFails(success)
114+
.then(() => {
115+
throw new Error('Expected success to fail.');
116+
})
117+
.catch(() => {});
118+
119+
await firebase.assertFails(permissionDenied).catch(() => {
120+
throw new Error('Expected permissionDenied to succeed.');
121+
});
122+
123+
await firebase
124+
.assertFails(otherFailure)
125+
.then(() => {
126+
throw new Error('Expected otherFailure to fail.');
127+
})
128+
.catch(() => {});
129+
});
130+
106131
it('initializeTestApp() with auth=null does not set access token', async function () {
107132
const app = firebase.initializeTestApp({
108133
projectId: 'foo',

0 commit comments

Comments
 (0)