Skip to content

Commit

Permalink
Merge pull request #1168 from pact-foundation/fix/issue-848
Browse files Browse the repository at this point in the history
fix: support multiple states with same name
  • Loading branch information
YOU54F authored Jan 23, 2024
2 parents a5c5ee1 + f8ea427 commit 425603c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
4 changes: 1 addition & 3 deletions src/messageConsumerPact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ export class MessageConsumerPact {
if (typeof state === 'string') {
this.message.given(state);
} else {
forEachObjIndexed((v, k) => {
this.message.givenWithParam(state.name, `${k}`, JSON.stringify(v));
}, state.params);
this.message.givenWithParams(state.name, JSON.stringify(state.params));
}

return this;
Expand Down
13 changes: 5 additions & 8 deletions src/v3/pact.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forEachObjIndexed, equals } from 'ramda';
import { equals } from 'ramda';
import {
makeConsumerPact,
ConsumerPact,
Expand Down Expand Up @@ -97,13 +97,10 @@ export class PactV3 {
this.interaction = this.pact.newInteraction(description);
this.states.forEach((s) => {
if (s.parameters) {
forEachObjIndexed((v, k) => {
this.interaction.givenWithParam(
s.description,
`${k}`,
JSON.stringify(v)
);
}, s.parameters);
this.interaction.givenWithParams(
s.description,
JSON.stringify(s.parameters)
);
} else {
this.interaction.given(s.description);
}
Expand Down
4 changes: 1 addition & 3 deletions src/v4/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export class UnconfiguredInteraction implements V4UnconfiguredInteraction {

given(state: string, parameters?: JsonMap): V4UnconfiguredInteraction {
if (parameters) {
forEachObjIndexed((v, k) => {
this.interaction.givenWithParam(state, `${k}`, JSON.stringify(v));
}, parameters);
this.interaction.givenWithParams(state, JSON.stringify(parameters));
} else {
this.interaction.given(state);
}
Expand Down
4 changes: 1 addition & 3 deletions src/v4/message/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export class UnconfiguredSynchronousMessage

given(state: string, parameters?: JsonMap): V4UnconfiguredSynchronousMessage {
if (parameters) {
forEachObjIndexed((v, k) => {
this.interaction.givenWithParam(state, `${k}`, JSON.stringify(v));
}, parameters);
this.interaction.givenWithParams(state, JSON.stringify(parameters));
} else {
this.interaction.given(state);
}
Expand Down

0 comments on commit 425603c

Please sign in to comment.