-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make verifier a nestjs provider again
- Loading branch information
1 parent
5cab2ac
commit df4249d
Showing
9 changed files
with
83 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Test } from '@nestjs/testing'; | ||
import { Verifier } from '@pact-foundation/pact-core'; | ||
import { PactModuleProviders } from '../common/pact-module-providers.enum'; | ||
import { PactVerifierProvider } from './pact-verifier.provider'; | ||
import { PactProviderOptions } from '../interfaces/pact-provider-module-options.interface'; | ||
|
||
const mockVerifier = jest.createMockFromModule<Verifier>('@pact-foundation/pact-core'); | ||
|
||
mockVerifier.verify = jest.fn(); | ||
|
||
describe('PactVerifierProvider', () => { | ||
const providerOptions: PactProviderOptions = { providerBaseUrl: 'http://127.0.0.1:80' }; | ||
|
||
beforeAll(async () => { | ||
await Test.createTestingModule({ | ||
providers: [ | ||
PactVerifierProvider, | ||
{ | ||
provide: PactModuleProviders.ProviderOptions, | ||
useValue: providerOptions, | ||
}, | ||
], | ||
}).compile(); | ||
}); | ||
|
||
describe('When calling the provider (in any module)', () => { | ||
test('then call Verifier with the exact options', () => { | ||
expect(Verifier).toHaveBeenCalledWith(providerOptions); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Provider } from '@nestjs/common'; | ||
import { Verifier } from '@pact-foundation/pact'; | ||
import { PactModuleProviders } from '../common/pact-module-providers.enum'; | ||
import { PactProviderOptions } from '../interfaces/pact-provider-module-options.interface'; | ||
|
||
export const PactVerifierProvider: Provider<Verifier> = { | ||
provide: PactModuleProviders.PactVerifier, | ||
useFactory: (config: PactProviderOptions) => new Verifier(config), | ||
inject: [PactModuleProviders.ProviderOptions], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters