Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module('Pact | People', function(hooks) {
// Record the state(s) the provider should be in prior to the interaction under test.
// When verifying the generated pact document against the 'my-api' provider later,
// its own 'a person exists' state will be invoked with the same parameters.
given('a person exists', { id: '123', name: 'Alice' });
const person = given('a person exists', { id: '123', name: 'Alice' });

// Perform the interaction that this test is intended to record, in this case
// fetching a particular person record by ID.
Expand Down Expand Up @@ -481,7 +481,7 @@ For instance, the `'a person exists'` provider state described above could be de
import { providerState } from 'ember-cli-pact';

providerState('a person exists', (server, { id, name }) => {
server.create('person', { id, name });
return server.create('person', { id, name });
});
```

Expand Down
2 changes: 1 addition & 1 deletion addon-test-support/-private/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class Interaction {
}

addProviderState(name, params) {
this.providerStates.push({ name, params });
return this.providerStates.push({ name, params });
}

recordRequest(request) {
Expand Down
3 changes: 2 additions & 1 deletion addon-test-support/mock-provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ export default class MockProvider {
* @method addState
* @param {string} name
* @param {object} [params]
* @return {number}
*/
addState(name, params) {
this.interaction.addProviderState(name, params);
return this.interaction.addProviderState(name, params);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure how to proceed here. I am returning whatever is returned by addProviderState.

}

/**
Expand Down
2 changes: 1 addition & 1 deletion addon-test-support/mock-provider/mirage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class MirageProvider extends MockProvider {

let state = this.lookupProviderState(name);
assert('Mirage provider states require a callback function', typeof state.config === 'function');
state.config.call(null, this.server, params);
return state.config.call(null, this.server, params);
}

endInteraction() {
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/pact-provider-states/beds.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { providerState } from 'ember-cli-pact';

providerState('a bed exists', (server, { id, size }) => {
server.create('bed', { id, size });
return server.create('bed', { id, size });
});
6 changes: 4 additions & 2 deletions tests/pact/beds-mocha-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ describe('Pact | Beds', function() {
setupPact();

beforeEach(function() {
given('a bed exists', { id: '1', size: 'double' });
given('a bed exists', { id: '2', size: 'queen' });
this.bed1 = given('a bed exists', { id: '1', size: 'double' });
this.bed2 = given('a bed exists', { id: '2', size: 'queen' });
});

it('listing beds', async function() {
let beds = await interaction(() => this.store().findAll('bed'));
assert.equal(this.bed1.id, 1);
assert.equal(this.bed2.id, 2);

assert.deepEqual([...beds.mapBy('id')], ['1', '2']);
assert.deepEqual([...beds.mapBy('size')], ['double', 'queen']);
Expand Down
6 changes: 4 additions & 2 deletions tests/pact/beds-qunit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ module('Pact | Beds', function(hooks) {
setupPact(hooks);

hooks.beforeEach(function() {
given('a bed exists', { id: '1', size: 'double' });
given('a bed exists', { id: '2', size: 'queen' });
this.bed1 = given('a bed exists', { id: '1', size: 'double' });
this.bed2 = given('a bed exists', { id: '2', size: 'queen' });
});

test('listing beds', async function(assert) {
let beds = await interaction(() => this.store().findAll('bed'));
assert.equal(this.bed1.id, 1);
assert.equal(this.bed2.id, 2);

assert.deepEqual([...beds.mapBy('id')], ['1', '2']);
assert.deepEqual([...beds.mapBy('size')], ['double', 'queen']);
Expand Down