This repository was archived by the owner on May 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathfirebase-auth.html
More file actions
136 lines (113 loc) · 3.92 KB
/
firebase-auth.html
File metadata and controls
136 lines (113 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!doctype html>
<!--
@license
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://github.com/firebase/polymerfire/blob/master/LICENSE
-->
<html>
<head>
<meta charset="UTF-8">
<title>firebase-auth tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../firebase-app.html">
<link rel="import" href="../firebase-auth.html">
</head>
<body>
<firebase-app
name="test"
api-key="AIzaSyDTP-eiQezleFsV2WddFBAhF_WEzx_8v_g"
auth-domain="polymerfire-test.firebaseapp.com"
database-url="https://polymerfire-test.firebaseio.com">
</firebase-app>
<test-fixture id="BasicAuth">
<template>
<firebase-auth
app-name="test">
</firebase-auth>
</template>
</test-fixture>
<test-fixture id="RefreshAuth">
<template>
<firebase-auth
app-name="test">
</firebase-auth>
</template>
</test-fixture>
<test-fixture id="DynamicAuth">
<template>
<firebase-auth
app-name="test">
</firebase-auth>
</template>
</test-fixture>
<test-fixture id="DynamicAuth">
<template>
<firebase-auth
app-name="test">
</firebase-auth>
</template>
</test-fixture>
<script>
suite('firebase-auth', function() {
var authElement;
suite('with no configured provider', function() {
setup(function() {
authElement = fixture('BasicAuth');
});
test('has an auth instance', function() {
expect(authElement.auth).to.be.ok;
});
test('eventually signs in', function() {
return authElement.signInAnonymously().then(function(user) {
expect(user.uid).to.be.ok;
});
});
test('statusKnown state change', function(done) {
var originalElement = fixture('RefreshAuth');
//These credentials have been previously created in polyfire-test
const email = 'test.1465417606005@polyfiretestdomain.com';
const password = 'polyfiretestdomain';
expect(originalElement.statusKnown).to.be.equal(false);
originalElement.signInWithEmailAndPassword(email, 'polyfiretestdomain')
.then(function (user) {
//Verify the sign in results
expect(user.uid).to.be.ok;
expect(originalElement.statusKnown).to.be.equal(true);
expect(user.email).to.be.equal(email);
//Create another firebase element
var dynamicAuth = fixture("DynamicAuth");
//Verify the initial state: statusKnown = false and user is null
expect(dynamicAuth.user).to.be.equal(null);
expect(dynamicAuth.statusKnown).to.be.equal(false);
//Wait for the status-known event to be thrown (set in
dynamicAuth.addEventListener('status-known-changed', function(event) {
if (event.detail.value) {
//Verify the final state: statusKnown = false and user is null
expect(dynamicAuth.statusKnown).to.be.equal(true);
expect(dynamicAuth.user.uid).to.be.ok;
expect(dynamicAuth.user.email).to.be.equal(email);
done();
} else {
expect(dynamicAuth.statusKnown).to.be.equal(false);
}
});
});
});
test('failed promises should be forwarded', function() {
expect(authElement.user).to.be.equal(null);
expect(authElement.statusKnown).to.be.equal(false);
return authElement.signInWithEmailAndPassword('', '').then(function(user) {
throw 'sign in with email and password should not have succeeded';
}).catch(function(err) {
expect(err).to.be.ok;
expect(authElement.statusKnown).to.be.equal(true);
});
});
});
});
</script>
</body>