Skip to content

Commit

Permalink
fix(test): update all mainline tests to match new API
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Feb 19, 2017
1 parent 381bf9d commit 936a75d
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 234 deletions.
1 change: 1 addition & 0 deletions src/dsl/mockService.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = class MockService {
* @returns {Promise}
*/
removeInteractions () {
console.log('removing interactions')
return this._request.send('DELETE', `${this._baseURL}/interactions`)
}

Expand Down
23 changes: 9 additions & 14 deletions src/pact.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const Interaction = require('./dsl/interaction')
const responseParser = require('./common/responseParser').parse
const serviceFactory = require('@pact-foundation/pact-node')
const clc = require('cli-color')
const path = require('path')

/**
* Creates a new {@link PactProvider}.
* @memberof Pact
Expand Down Expand Up @@ -67,9 +69,7 @@ module.exports = (opts) => {
* Start the Mock Server.
* @returns {Promise}
*/
setup: () => {
return server.start()
},
setup: () => server.start(),

/**
* Add an interaction to the {@link MockService}.
Expand Down Expand Up @@ -101,9 +101,7 @@ module.exports = (opts) => {
* @returns {Promise}
*/
verify: () => {
console.log('verify()')
return mockService.verify()
// .then(mockService.removeInteractions)
.then(() => { mockService.removeInteractions() })
.catch(e => {
// Properly format the error
Expand All @@ -114,16 +112,16 @@ module.exports = (opts) => {
throw new Error('Pact verification failed - expected interactions did not match actual.')
})
},

/**
* Writes the Pact and clears any interactions left behind and shutdown the
* mock server
* @memberof PactProvider
* @instance
* @returns {Promise}
*/
finalize: () => {
return mockService.writePact().then(() => server.delete())
},
finalize: () => mockService.writePact().then(() => server.delete()),

/**
* Writes the pact file out to file. Should be called when all tests have been performed for a
* given Consumer <-> Provider pair. It will write out the Pact to the
Expand All @@ -132,18 +130,15 @@ module.exports = (opts) => {
* @instance
* @returns {Promise}
*/
writePact: () => {
return mockService.writePact()
},
writePact: () => mockService.writePact(),

/**
* Clear up any interactions in the Provider Mock Server.
* @memberof PactProvider
* @instance
* @returns {Promise}
*/
removeInteractions: () => {
return mockService.removeInteractions()
}
removeInteractions: () => mockService.removeInteractions()
}
}

Expand Down
Loading

0 comments on commit 936a75d

Please sign in to comment.