Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Add better type info and documentation to SkyPactService. #430

Merged
merged 4 commits into from
Jul 17, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions runtime/pact.service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PactWeb } from '@pact-foundation/pact-web';
import { InteractionObject } from '@pact-foundation/pact-web/dsl/interaction';
import { SkyAppConfig } from '@blackbaud/skyux-builder/runtime/config';

declare var Pact: any;
Expand All @@ -7,7 +9,7 @@ declare var Pact: any;
*/
export class SkyPactService {

private pactProviders: { [providerName: string]: any } = {};
private pactProviders: { [providerName: string]: PactWeb } = {};

private matchersInternal: any;

Expand All @@ -27,28 +29,37 @@ export class SkyPactService {
this.matchersInternal = Pact.Matchers;
}

public addInteraction(provider: string, interaction: any) {

/**
* Add an interaction to the Mock Service.
* @param provider The name of the provider service.
* @param interaction The provider interaction.
*/
public addInteraction(provider: string, interaction: InteractionObject): Promise<string> {
return this.pactProviders[provider].addInteraction(interaction);

}

public removeInteractions(provider: string) {

/**
* Clear up any interactions in the Mock Service.
* @param provider The name of the provider service.
*/
public removeInteractions(provider: string): Promise<string> {
return this.pactProviders[provider].removeInteractions();

}

public finalize(provider: string) {

/**
* Writes the Pact file and clears any interactions left behind.
* @param provider The name of the provider service.
*/
public finalize(provider: string): Promise<string> {
return this.pactProviders[provider].finalize();

}

public verify(provider: string) {

/**
* Checks with the Mock Service if the expected interactions have been exercised.
* @param provider The name of the provider service.
*/
public verify(provider: string): Promise<string> {
return this.pactProviders[provider].verify();

}

public get matchers() {
Expand Down