-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathmessaging.spec.ts
41 lines (35 loc) · 1.27 KB
/
messaging.spec.ts
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
import { TestBed } from '@angular/core/testing';
import { getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';
import { Messaging, getMessaging, isSupported, provideMessaging } from '@angular/fire/messaging';
import { COMMON_CONFIG } from '../test-config';
import { rando } from '../utils';
describe('Messaging', () => {
let messaging: Messaging;
let providedMessaging: Messaging;
let appName: string;
describe('single injection', () => {
beforeEach(() => {
appName = rando();
TestBed.configureTestingModule({
providers: [
provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),
provideMessaging(() => {
providedMessaging = getMessaging(getApp(appName));
return providedMessaging;
}),
],
});
messaging = TestBed.inject(Messaging);
});
it('should be injectable', async () => {
const supported = await TestBed.runInInjectionContext(isSupported);
if (supported) {
expect(providedMessaging).toBeTruthy();
expect(messaging).toEqual(providedMessaging);
} else {
expect(providedMessaging).toBeUndefined();
expect(messaging).toBeNull();
}
});
});
});