File tree 2 files changed +28
-1
lines changed
packages/rules-unit-testing
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -698,7 +698,9 @@ export function assertFails(pr: Promise<any>): any {
698
698
errCode === 'permission-denied' ||
699
699
errCode === 'permission_denied' ||
700
700
errMessage . indexOf ( 'permission_denied' ) >= 0 ||
701
- errMessage . indexOf ( 'permission denied' ) >= 0 ;
701
+ errMessage . indexOf ( 'permission denied' ) >= 0 ||
702
+ // Storage permission errors contain message: (storage/unauthorized)
703
+ errMessage . indexOf ( 'unauthorized' ) >= 0 ;
702
704
703
705
if ( ! isPermissionDenied ) {
704
706
return Promise . reject (
Original file line number Diff line number Diff line change @@ -153,6 +153,31 @@ describe('Testing Module Tests', function () {
153
153
. catch ( ( ) => { } ) ;
154
154
} ) ;
155
155
156
+ it ( 'assertFails() if message contains unauthorized' , async function ( ) {
157
+ const success = Promise . resolve ( 'success' ) ;
158
+ const permissionDenied = Promise . reject ( {
159
+ message : 'User does not have permission to access \'file\'. (storage/unauthorized)'
160
+ } ) ;
161
+ const otherFailure = Promise . reject ( 'failure' ) ;
162
+ await firebase
163
+ . assertFails ( success )
164
+ . then ( ( ) => {
165
+ throw new Error ( 'Expected success to fail.' ) ;
166
+ } )
167
+ . catch ( ( ) => { } ) ;
168
+
169
+ await firebase . assertFails ( permissionDenied ) . catch ( ( ) => {
170
+ throw new Error ( 'Expected permissionDenied to succeed.' ) ;
171
+ } ) ;
172
+
173
+ await firebase
174
+ . assertFails ( otherFailure )
175
+ . then ( ( ) => {
176
+ throw new Error ( 'Expected otherFailure to fail.' ) ;
177
+ } )
178
+ . catch ( ( ) => { } ) ;
179
+ } ) ;
180
+
156
181
it ( 'discoverEmulators() finds all running emulators' , async ( ) => {
157
182
const options = await firebase . discoverEmulators ( ) ;
158
183
You can’t perform that action at this time.
0 commit comments