-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathfiam.e2e.js
112 lines (100 loc) · 4.43 KB
/
fiam.e2e.js
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
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
describe('inAppMessaging()', function () {
// TODO Conflicts with Modular tests in Jet,
// Ignore for now since v8 compat going away eventually
xdescribe('v8 compatibility', function () {
describe('namespace', function () {
it('accessible from firebase.app()', function () {
const app = firebase.app();
should.exist(app.inAppMessaging);
app.inAppMessaging().app.should.equal(app);
});
});
describe('setAutomaticDataCollectionEnabled()', function () {
// These depend on `tests/firebase.json` having `in_app_messaging_auto_collection_enabled` set to false the first time
// The setting is persisted across restarts, reset to false after for local runs where prefs are sticky
afterEach(async function () {
await firebase.inAppMessaging().setAutomaticDataCollectionEnabled(false);
});
it('true', async function () {
should.equal(firebase.inAppMessaging().isAutomaticDataCollectionEnabled, false);
await firebase.inAppMessaging().setAutomaticDataCollectionEnabled(true);
should.equal(firebase.inAppMessaging().isAutomaticDataCollectionEnabled, true);
});
it('false', async function () {
await firebase.inAppMessaging().setAutomaticDataCollectionEnabled(false);
should.equal(firebase.inAppMessaging().isAutomaticDataCollectionEnabled, false);
});
it('errors if not boolean', async function () {
try {
firebase.inAppMessaging().setAutomaticDataCollectionEnabled();
return Promise.reject(new Error('Did not throw'));
} catch (e) {
e.message.should.containEql('must be a boolean');
return Promise.resolve();
}
});
});
});
describe('modular', function () {
// TODO flakey on Jet tests
xdescribe('setAutomaticDataCollectionEnabled()', function () {
// These depend on `tests/firebase.json` having `in_app_messaging_auto_collection_enabled` set to false the first time
// The setting is persisted across restarts, reset to false after for local runs where prefs are sticky
afterEach(async function () {
await firebase.inAppMessaging().setAutomaticDataCollectionEnabled(false);
});
// afterEach(async function () {
// const { getInAppMessaging, setAutomaticDataCollectionEnabled } = inAppMessagingModular;
// const inAppMessaging = getInAppMessaging();
// await setAutomaticDataCollectionEnabled(inAppMessaging, false);
// });
it('true', async function () {
const {
getInAppMessaging,
setAutomaticDataCollectionEnabled,
isAutomaticDataCollectionEnabled,
} = inAppMessagingModular;
const inAppMessaging = getInAppMessaging();
should.equal(isAutomaticDataCollectionEnabled(inAppMessaging), false);
await setAutomaticDataCollectionEnabled(inAppMessaging, true);
should.equal(isAutomaticDataCollectionEnabled(inAppMessaging), true);
});
it('false', async function () {
const {
getInAppMessaging,
setAutomaticDataCollectionEnabled,
isAutomaticDataCollectionEnabled,
} = inAppMessagingModular;
const inAppMessaging = getInAppMessaging();
await setAutomaticDataCollectionEnabled(inAppMessaging, false);
should.equal(isAutomaticDataCollectionEnabled(inAppMessaging), false);
});
it('errors if not boolean', async function () {
const { getInAppMessaging, setAutomaticDataCollectionEnabled } = inAppMessagingModular;
try {
await setAutomaticDataCollectionEnabled(getInAppMessaging());
return Promise.reject(new Error('Did not throw'));
} catch (e) {
e.message.should.containEql('must be a boolean');
return Promise.resolve();
}
});
});
});
});