Skip to content

Commit cdf2bb5

Browse files
committed
Rename ControllerInterface, which is a class, to BaseController
1 parent a6a7b16 commit cdf2bb5

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

packages/messaging/src/controllers/controller-interface.ts renamed to packages/messaging/src/controllers/base-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const SENDER_ID_OPTION_NAME = 'messagingSenderId';
4040
// Database cache should be invalidated once a week.
4141
export const TOKEN_EXPIRATION_MILLIS = 7 * 24 * 60 * 60 * 1000; // 7 days
4242

43-
export abstract class ControllerInterface implements FirebaseMessaging {
43+
export abstract class BaseController implements FirebaseMessaging {
4444
app: FirebaseApp;
4545
INTERNAL: FirebaseServiceInternals;
4646
private readonly messagingSenderId: string;

packages/messaging/src/controllers/sw-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ import {
2929
MessageParameter,
3030
MessageType
3131
} from '../models/worker-page-message';
32-
import { BgMessageHandler, ControllerInterface } from './controller-interface';
32+
import { BaseController, BgMessageHandler } from './base-controller';
3333

3434
// Let TS know that this is a service worker
3535
declare const self: ServiceWorkerGlobalScope;
3636

3737
const FCM_MSG = 'FCM_MSG';
3838

39-
export class SwController extends ControllerInterface {
39+
export class SwController extends BaseController {
4040
private bgMessageHandler: BgMessageHandler | null = null;
4141

4242
constructor(app: FirebaseApp) {

packages/messaging/src/controllers/window-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ import {
3434
MessageParameter,
3535
MessageType
3636
} from '../models/worker-page-message';
37-
import { ControllerInterface } from './controller-interface';
37+
import { BaseController } from './base-controller';
3838

3939
interface ManifestContent {
4040
gcm_sender_id: string;
4141
}
4242

43-
export class WindowController extends ControllerInterface {
43+
export class WindowController extends BaseController {
4444
private registrationToUse: ServiceWorkerRegistration | null = null;
4545
private publicVapidKeyToUse: Uint8Array | null = null;
4646
private manifestCheckPromise: Promise<void> | null = null;

packages/messaging/test/controller-get-token.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import * as sinon from 'sinon';
1818

1919
import { FirebaseApp } from '@firebase/app-types';
2020

21-
import { ControllerInterface } from '../src/controllers/controller-interface';
21+
import { BaseController } from '../src/controllers/base-controller';
2222
import { SwController } from '../src/controllers/sw-controller';
2323
import { WindowController } from '../src/controllers/window-controller';
2424
import { base64ToArrayBuffer } from '../src/helpers/base64-to-array-buffer';
@@ -141,7 +141,7 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
141141

142142
it('should handle a failure to get registration', () => {
143143
sandbox
144-
.stub(ControllerInterface.prototype, 'getNotificationPermission_')
144+
.stub(BaseController.prototype, 'getNotificationPermission_')
145145
.callsFake(() => 'granted');
146146

147147
sandbox
@@ -169,7 +169,7 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
169169

170170
it('should handle the notification permission', () => {
171171
const notificationStub = sandbox.stub(
172-
ControllerInterface.prototype,
172+
BaseController.prototype,
173173
'getNotificationPermission_'
174174
);
175175
notificationStub.onCall(0).returns('denied');
@@ -231,7 +231,7 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
231231
.callsFake(() => Promise.resolve(vapidKeyToUse));
232232

233233
sandbox
234-
.stub(ControllerInterface.prototype, 'getNotificationPermission_')
234+
.stub(BaseController.prototype, 'getNotificationPermission_')
235235
.callsFake(() => 'granted');
236236

237237
sandbox
@@ -260,7 +260,7 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
260260
.callsFake(() => Promise.resolve(CUSTOM_VAPID_KEY));
261261

262262
sandbox
263-
.stub(ControllerInterface.prototype, 'getNotificationPermission_')
263+
.stub(BaseController.prototype, 'getNotificationPermission_')
264264
.callsFake(() => 'granted');
265265

266266
sandbox
@@ -281,7 +281,7 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
281281
mockGetReg(Promise.resolve(registration));
282282

283283
sandbox
284-
.stub(ControllerInterface.prototype, 'getNotificationPermission_')
284+
.stub(BaseController.prototype, 'getNotificationPermission_')
285285
.callsFake(() => 'granted');
286286

287287
sandbox
@@ -330,7 +330,7 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
330330
};
331331

332332
sandbox
333-
.stub(ControllerInterface.prototype, 'getNotificationPermission_')
333+
.stub(BaseController.prototype, 'getNotificationPermission_')
334334
.callsFake(() => 'granted');
335335

336336
sandbox
@@ -408,7 +408,7 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
408408
saveTokenDetailsStub.callsFake(async () => {});
409409

410410
sandbox
411-
.stub(ControllerInterface.prototype, 'getNotificationPermission_')
411+
.stub(BaseController.prototype, 'getNotificationPermission_')
412412
.callsFake(() => 'granted');
413413

414414
let vapidKeyToUse = DEFAULT_PUBLIC_VAPID_KEY;
@@ -482,7 +482,7 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
482482
mockGetReg(regPromise);
483483

484484
sandbox
485-
.stub(ControllerInterface.prototype, 'getNotificationPermission_')
485+
.stub(BaseController.prototype, 'getNotificationPermission_')
486486
.callsFake(() => 'granted');
487487

488488
// start with using the deault key.
@@ -567,7 +567,7 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
567567
const errorMsg = 'messaging/' + ERROR_CODES.TOKEN_UPDATE_FAILED;
568568

569569
sandbox
570-
.stub(ControllerInterface.prototype, 'getNotificationPermission_')
570+
.stub(BaseController.prototype, 'getNotificationPermission_')
571571
.callsFake(() => 'granted');
572572

573573
sandbox

packages/messaging/test/controller-interface.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { FirebaseApp } from '@firebase/app-types';
1818
import { expect } from 'chai';
1919
import * as sinon from 'sinon';
2020

21-
import { ControllerInterface } from '../src/controllers/controller-interface';
21+
import { BaseController } from '../src/controllers/base-controller';
2222
import { SwController } from '../src/controllers/sw-controller';
2323
import { WindowController } from '../src/controllers/window-controller';
2424
import { DEFAULT_PUBLIC_VAPID_KEY } from '../src/models/fcm-details';
@@ -34,10 +34,10 @@ import { describe } from './testing-utils/messaging-test-runner';
3434
const controllersToTest = [WindowController, SwController];
3535

3636
/**
37-
* As ControllerInterface is an abstract class, we need a concrete
37+
* As BaseController is an abstract class, we need a concrete
3838
* implementation that can be initialized for testing
3939
*/
40-
class MockControllerInterface extends ControllerInterface {
40+
class MockBaseController extends BaseController {
4141
async getSWRegistration_(): Promise<ServiceWorkerRegistration> {
4242
return new ServiceWorkerRegistration();
4343
}
@@ -47,7 +47,7 @@ class MockControllerInterface extends ControllerInterface {
4747
}
4848
}
4949

50-
describe('Firebase Messaging > *ControllerInterface', () => {
50+
describe('Firebase Messaging > *BaseController', () => {
5151
let sandbox: sinon.SinonSandbox;
5252
let app: FirebaseApp;
5353

@@ -64,7 +64,7 @@ describe('Firebase Messaging > *ControllerInterface', () => {
6464

6565
describe('INTERNAL.delete()', () => {
6666
it('should call delete()', () => {
67-
const controller = new MockControllerInterface(app);
67+
const controller = new MockBaseController(app);
6868
const spy = sandbox.spy(controller, 'delete');
6969
controller.INTERNAL.delete();
7070
expect(spy.callCount).to.equal(1);
@@ -73,7 +73,7 @@ describe('Firebase Messaging > *ControllerInterface', () => {
7373

7474
describe('requestPermission()', () => {
7575
it(`should throw`, () => {
76-
const controller = new MockControllerInterface(app);
76+
const controller = new MockBaseController(app);
7777
let thrownError;
7878
try {
7979
controller.requestPermission();
@@ -151,7 +151,7 @@ describe('Firebase Messaging > *ControllerInterface', () => {
151151

152152
describe('useServiceWorker()', () => {
153153
it(`should throw`, () => {
154-
const controller = new MockControllerInterface(app);
154+
const controller = new MockBaseController(app);
155155
let thrownError;
156156
try {
157157
controller.useServiceWorker(null as any);
@@ -165,7 +165,7 @@ describe('Firebase Messaging > *ControllerInterface', () => {
165165

166166
describe('usePublicVapidKey()', () => {
167167
it(`should throw`, () => {
168-
const controller = new MockControllerInterface(app);
168+
const controller = new MockBaseController(app);
169169
let thrownError;
170170
try {
171171
controller.usePublicVapidKey(null as any);
@@ -179,7 +179,7 @@ describe('Firebase Messaging > *ControllerInterface', () => {
179179

180180
describe('onMessage()', () => {
181181
it(`should throw`, () => {
182-
const controller = new MockControllerInterface(app);
182+
const controller = new MockBaseController(app);
183183
let thrownError;
184184
try {
185185
controller.onMessage(null as any, null as any, null as any);
@@ -193,7 +193,7 @@ describe('Firebase Messaging > *ControllerInterface', () => {
193193

194194
describe('onTokenRefresh()', () => {
195195
it(`should throw`, () => {
196-
const controller = new MockControllerInterface(app);
196+
const controller = new MockBaseController(app);
197197
let thrownError;
198198
try {
199199
controller.onTokenRefresh(null as any, null as any, null as any);
@@ -207,7 +207,7 @@ describe('Firebase Messaging > *ControllerInterface', () => {
207207

208208
describe('setBackgroundMessageHandler()', () => {
209209
it(`should throw`, () => {
210-
const controller = new MockControllerInterface(app);
210+
const controller = new MockBaseController(app);
211211
let thrownError;
212212
try {
213213
controller.setBackgroundMessageHandler(null as any);
@@ -222,31 +222,31 @@ describe('Firebase Messaging > *ControllerInterface', () => {
222222
describe('getNotificationPermission_', () => {
223223
it('should return current permission', () => {
224224
sandbox.stub(Notification as any, 'permission').value('test');
225-
const controller = new MockControllerInterface(app);
225+
const controller = new MockBaseController(app);
226226
const result = controller.getNotificationPermission_();
227227
expect(result).to.equal('test');
228228
});
229229
});
230230

231231
describe('getTokenDetailsModel', () => {
232232
it('should return an instance of TokenDetailsModel', () => {
233-
const controller = new MockControllerInterface(app);
233+
const controller = new MockBaseController(app);
234234
const result = controller.getTokenDetailsModel();
235235
expect(result).to.be.instanceof(TokenDetailsModel);
236236
});
237237
});
238238

239239
describe('getVapidDetailsModel', () => {
240240
it('should return an instance of VapidDetailsModel', () => {
241-
const controller = new MockControllerInterface(app);
241+
const controller = new MockBaseController(app);
242242
const result = controller.getVapidDetailsModel();
243243
expect(result).to.be.instanceof(VapidDetailsModel);
244244
});
245245
});
246246

247247
describe('getIidModel', () => {
248248
it('should return an instance of IidModel', () => {
249-
const controller = new MockControllerInterface(app);
249+
const controller = new MockBaseController(app);
250250
const result = controller.getIidModel();
251251
expect(result).to.be.instanceof(IidModel);
252252
});

0 commit comments

Comments
 (0)