|
| 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 | + |
| 21 | +import { testAuth, TestAuth } from '../../../test/helpers/mock_auth'; |
| 22 | +import { GetOobCodeRequest } from '../../api/authentication/email_and_password'; |
| 23 | +import { _setActionCodeSettingsOnRequest } from './action_code_settings'; |
| 24 | + |
| 25 | +describe('core/strategies/action_code_settings', () => { |
| 26 | + let auth: TestAuth; |
| 27 | + const request: GetOobCodeRequest = {}; |
| 28 | + |
| 29 | + beforeEach(async () => { |
| 30 | + auth = await testAuth(); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should require a non empty continue URL', () => { |
| 34 | + expect(() => |
| 35 | + _setActionCodeSettingsOnRequest(auth, request, { |
| 36 | + handleCodeInApp: true, |
| 37 | + iOS: { |
| 38 | + bundleId: 'my-bundle' |
| 39 | + }, |
| 40 | + url: '', |
| 41 | + dynamicLinkDomain: 'fdl-domain' |
| 42 | + }) |
| 43 | + ).to.throw(FirebaseError, '(auth/invalid-continue-uri)'); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should allow undefined dynamic link URL', () => { |
| 47 | + expect(() => |
| 48 | + _setActionCodeSettingsOnRequest(auth, request, { |
| 49 | + handleCodeInApp: true, |
| 50 | + iOS: { |
| 51 | + bundleId: 'my-´bundle' |
| 52 | + }, |
| 53 | + url: 'my-url' |
| 54 | + }) |
| 55 | + ).to.not.throw(); |
| 56 | + }); |
| 57 | + |
| 58 | + it('should require a non empty dynamic link URL', () => { |
| 59 | + expect(() => |
| 60 | + _setActionCodeSettingsOnRequest(auth, request, { |
| 61 | + handleCodeInApp: true, |
| 62 | + iOS: { |
| 63 | + bundleId: 'my-´bundle' |
| 64 | + }, |
| 65 | + url: 'my-url', |
| 66 | + dynamicLinkDomain: '' |
| 67 | + }) |
| 68 | + ).to.throw(FirebaseError, '(auth/invalid-dynamic-link-domain)'); |
| 69 | + }); |
| 70 | + |
| 71 | + it('should require a non-empty bundle ID', () => { |
| 72 | + expect(() => |
| 73 | + _setActionCodeSettingsOnRequest(auth, request, { |
| 74 | + handleCodeInApp: true, |
| 75 | + iOS: { |
| 76 | + bundleId: '' |
| 77 | + }, |
| 78 | + url: 'my-url', |
| 79 | + dynamicLinkDomain: 'fdl-domain' |
| 80 | + }) |
| 81 | + ).to.throw(FirebaseError, '(auth/missing-ios-bundle-id)'); |
| 82 | + }); |
| 83 | + |
| 84 | + it('should require a non-empty package name', () => { |
| 85 | + expect(() => |
| 86 | + _setActionCodeSettingsOnRequest(auth, request, { |
| 87 | + handleCodeInApp: true, |
| 88 | + android: { |
| 89 | + packageName: '' |
| 90 | + }, |
| 91 | + url: 'my-url', |
| 92 | + dynamicLinkDomain: 'fdl-domain' |
| 93 | + }) |
| 94 | + ).to.throw(FirebaseError, '(auth/missing-android-pkg-name)'); |
| 95 | + }); |
| 96 | +}); |
0 commit comments