-
Notifications
You must be signed in to change notification settings - Fork 985
Fix messaging being optional and isSupported type definitions #793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,12 @@ import { expect } from 'chai'; | |
| import { sandbox, SinonSandbox, SinonStub } from 'sinon'; | ||
|
|
||
| import { FirebaseApp } from '@firebase/app-types'; | ||
| import { _FirebaseNamespace } from '@firebase/app-types/private'; | ||
| import { | ||
| _FirebaseNamespace, | ||
| FirebaseServiceFactory | ||
| } from '@firebase/app-types/private'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be really nice to have a test that works like the docs suggests a user to, i.e. rather than poking at the internals like this :/
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I agree. The tests need an overhaul (not just here). I'll get to that soon™. |
||
|
|
||
| import { MessagingServiceFactory, registerMessaging } from '../index'; | ||
| import { registerMessaging } from '../index'; | ||
| import { ERROR_CODES } from '../src/models/errors'; | ||
|
|
||
| import { SwController } from '../src/controllers/sw-controller'; | ||
|
|
@@ -52,7 +55,7 @@ describe('Firebase Messaging > registerMessaging', () => { | |
| }); | ||
|
|
||
| describe('factoryMethod', () => { | ||
| let factoryMethod: MessagingServiceFactory; | ||
| let factoryMethod: FirebaseServiceFactory; | ||
| let fakeApp: FirebaseApp; | ||
|
|
||
| beforeEach(() => { | ||
|
|
@@ -65,8 +68,9 @@ describe('Firebase Messaging > registerMessaging', () => { | |
| }); | ||
|
|
||
| describe('isSupported', () => { | ||
| it('is a static method on factoryMethod', () => { | ||
| expect(factoryMethod.isSupported).to.be.a('function'); | ||
| it('is a namespace export', () => { | ||
| const namespaceExports = registerService.getCall(0).args[2]; | ||
| expect(namespaceExports.isSupported).to.be.a('function'); | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soo... @firebase/messaging is optional; you can use @firebase/database etc. but not messaging just fine.
firebase the metapackage bundles everything together, cool.
But if you just depend on @firebase/messaging, it would monkey-patch @firebase/app-types to add itself optionally? weird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are all optional (you can import them or not), but if you import them, then the namespace exists (and the type should not be "optional" anymore). I'm not sure why that
?ever existed, I'm hoping @jshcrowthe has an idea.