Login is false when network fails

getLoggedIn catches errors and it returns false on being logged in.
Gr-router preheat getLoggedIn and we want to return result in any case

Change-Id: I8454f89bced801da7e9a0f287c8fb6e2c5446dc5
This commit is contained in:
Milutin Kristofic
2019-08-07 11:07:20 +02:00
parent 4f06d74558
commit 388bc904c0
2 changed files with 11 additions and 0 deletions

View File

@@ -1095,6 +1095,8 @@
getLoggedIn() {
return this.getAccount().then(account => {
return account != null;
}).catch(() => {
return false;
});
},

View File

@@ -494,6 +494,15 @@ limitations under the License.
});
});
test('getLoggedIn returns false when network/auth failure', done => {
window.fetch.returns(
Promise.reject(new Error('Failed to fetch')));
element.getLoggedIn().then(isLoggedIn => {
assert.isFalse(isLoggedIn);
done();
});
});
test('checkCredentials', done => {
const responses = [
{