|
21 | 21 | // SOFTWARE.
|
22 | 22 |
|
23 | 23 | import 'mocha';
|
24 |
| -import './lifecycle.spec'; |
25 |
| -import './main.spec'; |
26 |
| -import './app.spec'; |
27 | 24 | import { expect } from 'chai';
|
28 | 25 |
|
29 |
| -/* tslint:disable-next-line:no-var-requires */ |
30 |
| -const indexExport = require('../src')(); |
31 |
| - |
32 | 26 | describe('index', () => {
|
| 27 | + /* tslint:disable-next-line:no-var-requires */ |
| 28 | + const indexExport = require('../src')({ projectId: 'fakeProject' }, 'fakeServiceAccount'); |
33 | 29 | after(() => {
|
34 | 30 | // Call cleanup (handles case of cleanup function not existing)
|
35 | 31 | indexExport.cleanup && indexExport.cleanup();
|
36 | 32 | });
|
37 | 33 |
|
38 |
| - it('should export wrap as a function', () => { |
39 |
| - expect(indexExport.wrap).to.be.an('function'); |
| 34 | + it('should export the expected functions and namespaces', () => { |
| 35 | + expect(Object.getOwnPropertyNames(indexExport).sort()).to.deep.equal([ |
| 36 | + 'analytics', |
| 37 | + 'auth', |
| 38 | + 'cleanup', |
| 39 | + 'crashlytics', |
| 40 | + 'database', |
| 41 | + 'firestore', |
| 42 | + 'makeChange', |
| 43 | + 'mockConfig', |
| 44 | + 'pubsub', |
| 45 | + 'storage', |
| 46 | + 'wrap', |
| 47 | + ]); |
40 | 48 | });
|
41 | 49 |
|
42 |
| - it('should export makeChange as a function', () => { |
43 |
| - expect(indexExport.makeChange).to.be.an('function'); |
| 50 | + it('should set env variables based parameters SDK was initialized with', () => { |
| 51 | + expect(process.env.FIREBASE_CONFIG).to.equal(JSON.stringify({ projectId: 'fakeProject' })); |
| 52 | + expect(process.env.GOOGLE_APPLICATION_CREDENTIALS).to.equal('fakeServiceAccount'); |
44 | 53 | });
|
45 | 54 |
|
46 |
| - it('should export mockConfig as a function', () => { |
47 |
| - expect(indexExport.mockConfig).to.be.an('function'); |
48 |
| - }); |
49 |
| - |
50 |
| - it('should export cleanup as a function', () => { |
51 |
| - expect(indexExport.cleanup).to.be.an('function'); |
| 55 | + it('should clean up env variables once cleanup is called', () => { |
| 56 | + indexExport.cleanup(); |
| 57 | + expect(process.env.FIREBASE_CONFIG).to.equal(undefined); |
| 58 | + expect(process.env.GOOGLE_APPLICATION_CREDENTIALS).to.equal(undefined); |
52 | 59 | });
|
53 | 60 | });
|
54 | 61 |
|
| 62 | +import './lifecycle.spec'; |
| 63 | +import './main.spec'; |
| 64 | +import './app.spec'; |
55 | 65 | // import './providers/analytics.spec';
|
56 | 66 | // import './providers/auth.spec';
|
57 | 67 | // import './providers/database.spec';
|
|
0 commit comments