@@ -20,10 +20,7 @@ import * as sinon from 'sinon';
2020import { makeFakeApp } from './testing-utils/make-fake-app' ;
2121import { makeFakeSWReg } from './testing-utils/make-fake-sw-reg' ;
2222
23- import {
24- manifestCheck ,
25- WindowController
26- } from '../src/controllers/window-controller' ;
23+ import { WindowController } from '../src/controllers/window-controller' ;
2724import { base64ToArrayBuffer } from '../src/helpers/base64-to-array-buffer' ;
2825import { DEFAULT_PUBLIC_VAPID_KEY } from '../src/models/fcm-details' ;
2926
@@ -48,112 +45,6 @@ describe('Firebase Messaging > *WindowController', () => {
4845 return cleanup ( ) ;
4946 } ) ;
5047
51- describe ( 'manifestCheck()' , ( ) => {
52- it ( "should resolve when the tag isn't defined" , ( ) => {
53- sandbox
54- . stub ( document , 'querySelector' )
55- . withArgs ( 'link[rel="manifest"]' )
56- . returns ( null ) ;
57-
58- return manifestCheck ( ) ;
59- } ) ;
60-
61- it ( 'should fetch the manifest if defined and resolve when no gcm_sender_id' , ( ) => {
62- sandbox
63- . stub ( document , 'querySelector' )
64- . withArgs ( 'link[rel="manifest"]' )
65- . returns ( {
66- href : 'https://firebase.io/messaging/example'
67- } as any ) ;
68-
69- sandbox
70- . stub ( window , 'fetch' )
71- . withArgs ( 'https://firebase.io/messaging/example' )
72- . returns (
73- Promise . resolve ( {
74- json : ( ) => {
75- return { } ;
76- }
77- } as any )
78- ) ;
79-
80- return manifestCheck ( ) ;
81- } ) ;
82-
83- it ( 'should fetch the manifest if defined and resolve with expected gcm_sender_id' , ( ) => {
84- sandbox
85- . stub ( document , 'querySelector' )
86- . withArgs ( 'link[rel="manifest"]' )
87- . returns ( {
88- href : 'https://firebase.io/messaging/example'
89- } as any ) ;
90-
91- sandbox
92- . stub ( window , 'fetch' )
93- . withArgs ( 'https://firebase.io/messaging/example' )
94- . returns (
95- Promise . resolve ( {
96- json : ( ) => {
97- return {
98- // eslint-disable-next-line camelcase
99- gcm_sender_id : '103953800507'
100- } ;
101- }
102- } as any )
103- ) ;
104-
105- return manifestCheck ( ) ;
106- } ) ;
107-
108- it ( 'should fetch the manifest if defined and reject when using wrong gcm_sender_id' , ( ) => {
109- sandbox
110- . stub ( document , 'querySelector' )
111- . withArgs ( 'link[rel="manifest"]' )
112- . returns ( {
113- href : 'https://firebase.io/messaging/example'
114- } as any ) ;
115-
116- sandbox
117- . stub ( window , 'fetch' )
118- . withArgs ( 'https://firebase.io/messaging/example' )
119- . returns (
120- Promise . resolve ( {
121- json : ( ) => {
122- return {
123- // eslint-disable-next-line camelcase
124- gcm_sender_id : 'incorrect-sender-id'
125- } ;
126- }
127- } as any )
128- ) ;
129-
130- return manifestCheck ( ) . then (
131- ( ) => {
132- throw new Error ( 'Expected error to be thrown.' ) ;
133- } ,
134- err => {
135- expect ( err . code ) . to . equal ( 'messaging/incorrect-gcm-sender-id' ) ;
136- }
137- ) ;
138- } ) ;
139-
140- it ( 'should fetch the manifest and resolve if the request fails' , ( ) => {
141- sandbox
142- . stub ( document , 'querySelector' )
143- . withArgs ( 'link[rel="manifest"]' )
144- . returns ( {
145- href : 'https://firebase.io/messaging/example'
146- } as any ) ;
147-
148- sandbox
149- . stub ( window , 'fetch' )
150- . withArgs ( 'https://firebase.io/messaging/example' )
151- . returns ( Promise . reject ( new Error ( 'Injected Failure.' ) ) ) ;
152-
153- return manifestCheck ( ) ;
154- } ) ;
155- } ) ;
156-
15748 describe ( 'requestPermission' , ( ) => {
15849 it ( 'should resolve if the permission is already granted' , ( ) => {
15950 sandbox . stub ( Notification as any , 'permission' ) . value ( 'granted' ) ;
0 commit comments