Skip to content

Commit

Permalink
fix: fix FireormService provider
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbash committed Apr 5, 2021
1 parent c6e8f87 commit 8b55836
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/fireorm/fireorm.module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getRepositoryToken } from '../nestjs-fireorm';
import { FireormModule, FireormSettings, firestoreProvider } from './fireorm.module';
jest.mock('./fireorm.service');
import { FireormService } from './fireorm.service';
import 'jest-extended';
jest.mock('@google-cloud/firestore');
Expand Down Expand Up @@ -41,7 +42,18 @@ describe('FireormModule', () => {
inject: [FireormSettings],
useFactory: firestoreProvider,
},
FireormService,
{
provide: FireormService,
inject: [Firestore, FireormSettings],
useFactory: expect.toSatisfy((fun) => {
const fireormService = fun(1, 2);

expect(fireormService).toBeInstanceOf(FireormService);
expect(FireormService).toBeCalledWith(1, 2);

return true;
}),
},
],
exports: [FireormService],
});
Expand Down
7 changes: 6 additions & 1 deletion src/fireorm/fireorm.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ export class FireormModule {
inject: [FireormSettings],
useFactory: firestoreProvider,
},
FireormService,
{
provide: FireormService,
inject: [Firestore, FireormSettings],
useFactory: (firestore: Firestore, settings: FireormSettings) =>
new FireormService(firestore, settings),
},
],
exports: [FireormService],
};
Expand Down

0 comments on commit 8b55836

Please sign in to comment.