Skip to content

Commit

Permalink
feat(messages): implement v3 compatible provider states
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Apr 4, 2018
1 parent 578fecf commit 8e113a5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dsl/matchers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ describe("Matcher", () => {
});
});
describe("when given a complex nested object with matchers", () => {
it.only("should remove all matching guff", () => {
it("should remove all matching guff", () => {
const o = somethingLike({
stringMatcher: {
awesomeSetting: somethingLike("a string"),
Expand Down
2 changes: 1 addition & 1 deletion src/dsl/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface Metadata { [name: string]: string | MatcherResult; }
* @module Message
*/
export interface Message {
providerState?: string;
providerStates?: string;
description?: string;
metadata?: Metadata;
content: any;
Expand Down
12 changes: 12 additions & 0 deletions src/messageConsumer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ describe("MessageConsumer", () => {
return expect(consumer.validate()).to.eventually.be.fulfilled;
});
});
describe("when a valid state has been given", () => {
it("the state should be save id in v3 format", () => {
consumer
.given("some state")
.expectsToReceive("A message about something")
.withContent({ foo: "bar" })
.withMetadata({ baz: "bat" });

expect(consumer.json().providerStates).to.be.a("array");
expect(consumer.json().providerStates).to.deep.eq([{ name: "some state" }]);
});
});
describe("when a valid Message has not been constructed", () => {
it("the state should not be valid", () => {
consumer
Expand Down
7 changes: 6 additions & 1 deletion src/messageConsumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export class MessageConsumer {
*/
public given(providerState: string) {
if (providerState) {
this.state.providerState = providerState;
// Currently only supports a single state
// but the format needs to be v3 compatible for
// basic interoperability
this.state.providerStates = [{
name: providerState,
}];
}

return this;
Expand Down

0 comments on commit 8e113a5

Please sign in to comment.