1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import { FirebaseError } from '@firebase/util' ;
19
+ import { expect } from 'chai' ;
20
+ import { ActionCodeSettings } from '@firebase/auth-types-exp' ;
21
+
22
+ import { testAuth , TestAuth } from '../../../test/helpers/mock_auth' ;
23
+ import { GetOobCodeRequest } from '../../api/authentication/email_and_password' ;
24
+ import { setActionCodeSettingsOnRequest_ } from './action_code_settings' ;
25
+
26
+ describe ( 'core/strategies/action_code_settings' , ( ) => {
27
+ let auth : TestAuth ;
28
+ const request : GetOobCodeRequest = {
29
+ } ;
30
+
31
+ beforeEach ( async ( ) => {
32
+ auth = await testAuth ( ) ;
33
+ } ) ;
34
+
35
+
36
+ it ( 'should require a continue URL' , ( ) => {
37
+ expect ( ( ) =>
38
+ setActionCodeSettingsOnRequest_ ( auth , request , {
39
+ handleCodeInApp : true ,
40
+ iOS : {
41
+ bundleId : 'my-bundle'
42
+ } ,
43
+ dynamicLinkDomain : 'fdl-domain'
44
+ } as unknown as ActionCodeSettings )
45
+ ) . to . throw (
46
+ FirebaseError ,
47
+ '(auth/missing-continue-uri)'
48
+ ) ;
49
+ } ) ;
50
+
51
+ it ( 'should require a non empty continue URL' , ( ) => {
52
+ expect ( ( ) =>
53
+ setActionCodeSettingsOnRequest_ ( auth , request , {
54
+ handleCodeInApp : true ,
55
+ iOS : {
56
+ bundleId : 'my-bundle'
57
+ } ,
58
+ url : '' ,
59
+ dynamicLinkDomain : 'fdl-domain'
60
+ } )
61
+ ) . to . throw (
62
+ FirebaseError ,
63
+ '(auth/invalid-continue-uri)'
64
+ ) ;
65
+ } ) ;
66
+
67
+ it ( 'should allow undefined dynamic link URL' , ( ) => {
68
+ expect ( ( ) =>
69
+ setActionCodeSettingsOnRequest_ ( auth , request , {
70
+ handleCodeInApp : true ,
71
+ iOS : {
72
+ bundleId : 'my-´bundle'
73
+ } ,
74
+ url : 'my-url'
75
+ } )
76
+ ) . to . not . throw ( ) ;
77
+ } ) ;
78
+
79
+ it ( 'should require a non empty dynamic link URL' , ( ) => {
80
+ expect ( ( ) =>
81
+ setActionCodeSettingsOnRequest_ ( auth , request , {
82
+ handleCodeInApp : true ,
83
+ iOS : {
84
+ bundleId : 'my-´bundle'
85
+ } ,
86
+ url : 'my-url' ,
87
+ dynamicLinkDomain : ''
88
+ } )
89
+ ) . to . throw (
90
+ FirebaseError ,
91
+ '(auth/invalid-dynamic-link-domain)'
92
+ ) ;
93
+ } ) ;
94
+
95
+ it ( 'should require a non-empty bundle ID' , ( ) => {
96
+ expect ( ( ) =>
97
+ setActionCodeSettingsOnRequest_ ( auth , request , {
98
+ handleCodeInApp : true ,
99
+ iOS : {
100
+ bundleId : ''
101
+ } ,
102
+ url : 'my-url' ,
103
+ dynamicLinkDomain : 'fdl-domain'
104
+ } )
105
+ ) . to . throw (
106
+ FirebaseError ,
107
+ '(auth/missing-ios-bundle-id)'
108
+ ) ;
109
+ } ) ;
110
+
111
+ it ( 'should require a non-empty package name' , ( ) => {
112
+ expect ( ( ) =>
113
+ setActionCodeSettingsOnRequest_ ( auth , request , {
114
+ handleCodeInApp : true ,
115
+ android : {
116
+ packageName : ''
117
+ } ,
118
+ url : 'my-url' ,
119
+ dynamicLinkDomain : 'fdl-domain'
120
+ } )
121
+ ) . to . throw (
122
+ FirebaseError ,
123
+ '(auth/missing-android-pkg-name)'
124
+ ) ;
125
+ } ) ;
126
+ } ) ;
0 commit comments