forked from firebase/firebase-admin-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.spec.ts
More file actions
86 lines (77 loc) · 3.17 KB
/
app.spec.ts
File metadata and controls
86 lines (77 loc) · 3.17 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
/*!
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file 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.
*/
import * as admin from '../../lib/index';
import {expect} from 'chai';
import {
defaultApp, nullApp, nonNullApp, databaseUrl, projectId, storageBucket,
} from './setup';
describe('admin', () => {
it('populates required test parameters', () => {
expect(databaseUrl).to.be.not.empty;
expect(projectId).to.be.not.empty;
expect(storageBucket).to.be.not.empty;
});
it('does not load Firestore by default', () => {
const gcloud = require.cache[require.resolve('@google-cloud/firestore')];
expect(gcloud).to.be.undefined;
});
it('loads Firestore when calling admin.firestore', () => {
const firestoreNamespace = admin.firestore;
expect(firestoreNamespace).to.not.be.null;
const gcloud = require.cache[require.resolve('@google-cloud/firestore')];
expect(gcloud).to.not.be.undefined;
});
});
describe('admin.app', () => {
it('admin.app() returns the default App', () => {
const app = admin.app();
expect(app).to.deep.equal(defaultApp);
expect(app.name).to.equal('[DEFAULT]');
expect(app.options.databaseURL).to.equal(databaseUrl);
expect(app.options.databaseAuthVariableOverride).to.be.undefined;
expect(app.options.storageBucket).to.equal(storageBucket);
});
it('admin.app("null") returns the App named "null"', () => {
const app = admin.app('null');
expect(app).to.deep.equal(nullApp);
expect(app.name).to.equal('null');
expect(app.options.databaseURL).to.equal(databaseUrl);
expect(app.options.databaseAuthVariableOverride).to.be.null;
expect(app.options.storageBucket).to.equal(storageBucket);
});
it('admin.app("nonNull") returns the App named "nonNull"', () => {
const app = admin.app('nonNull');
expect(app).to.deep.equal(nonNullApp);
expect(app.name).to.equal('nonNull');
expect(app.options.databaseURL).to.equal(databaseUrl);
expect((app.options.databaseAuthVariableOverride as any).uid).to.be.ok;
expect(app.options.storageBucket).to.equal(storageBucket);
});
it('namespace services are attached to the default App', () => {
const app = admin.app();
expect(admin.auth(app).app).to.deep.equal(app);
expect(admin.database(app).app).to.deep.equal(app);
expect(admin.messaging(app).app).to.deep.equal(app);
expect(admin.storage(app).app).to.deep.equal(app);
});
it('namespace services are attached to the named App', () => {
const app = admin.app('null');
expect(admin.auth(app).app).to.deep.equal(app);
expect(admin.database(app).app).to.deep.equal(app);
expect(admin.messaging(app).app).to.deep.equal(app);
expect(admin.storage(app).app).to.deep.equal(app);
});
});