|
1 | 1 | /**
|
2 | 2 | * @license
|
3 |
| - * Copyright 2017 Google Inc. |
| 3 | + * Copyright 2017 Google LLC |
4 | 4 | *
|
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
6 | 6 | * you may not use this file except in compliance with the License.
|
@@ -135,6 +135,53 @@ function testValidatePersistenceArgument_node() {
|
135 | 135 | });
|
136 | 136 | }
|
137 | 137 |
|
| 138 | +function testValidatePersistenceArgument_worker() { |
| 139 | + // Simulate worker environment. |
| 140 | + stubs.replace( |
| 141 | + fireauth.util, |
| 142 | + 'getEnvironment', |
| 143 | + function() { |
| 144 | + return fireauth.util.Env.WORKER; |
| 145 | + }); |
| 146 | + // Simulate indexedDB supported. |
| 147 | + stubs.replace( |
| 148 | + fireauth.storage.IndexedDB, |
| 149 | + 'isAvailable', |
| 150 | + function() { |
| 151 | + return true; |
| 152 | + }); |
| 153 | + var unsupportedTypeError = new fireauth.AuthError( |
| 154 | + fireauth.authenum.Error.UNSUPPORTED_PERSISTENCE); |
| 155 | + // Session should throw an error. |
| 156 | + fireauth.common.testHelper.assertErrorEquals( |
| 157 | + unsupportedTypeError, |
| 158 | + assertThrows(function() { |
| 159 | + fireauth.authStorage.validatePersistenceArgument('session'); |
| 160 | + })); |
| 161 | + // Local should not throw an error when indexedDB is supported. |
| 162 | + assertNotThrows(function() { |
| 163 | + fireauth.authStorage.validatePersistenceArgument('local'); |
| 164 | + }); |
| 165 | + // None should be supported. |
| 166 | + assertNotThrows(function() { |
| 167 | + fireauth.authStorage.validatePersistenceArgument('none'); |
| 168 | + }); |
| 169 | + |
| 170 | + // Simulate indexedDB not supported. |
| 171 | + stubs.replace( |
| 172 | + fireauth.storage.IndexedDB, |
| 173 | + 'isAvailable', |
| 174 | + function() { |
| 175 | + return false; |
| 176 | + }); |
| 177 | + // Local should throw an error when indexedDB not supported. |
| 178 | + fireauth.common.testHelper.assertErrorEquals( |
| 179 | + unsupportedTypeError, |
| 180 | + assertThrows(function() { |
| 181 | + fireauth.authStorage.validatePersistenceArgument('local'); |
| 182 | + })); |
| 183 | +} |
| 184 | + |
138 | 185 |
|
139 | 186 | function testValidatePersistenceArgument_reactNative() {
|
140 | 187 | // Simulate React-Native.
|
|
0 commit comments