Skip to content

Commit

Permalink
#15 Backward compatibility for mockAnyResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdbloom committed May 3, 2017
1 parent 98643c8 commit db9cae9
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 34 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mockServerClient("localhost", 1080).
Or a more complex expectation can be setup as follows:

```js
mockServerClient("localhost", 1080).mockAnyExpectation(
mockServerClient("localhost", 1080).mockAnyResponse(
{
'httpRequest': {
'method': 'POST',
Expand Down Expand Up @@ -105,6 +105,7 @@ In lieu of a formal styleguide, take care to maintain the existing coding style.
* 2016-09-27   v1.0.11  Updated dependencies
* 2016-10-09   v1.0.12  Resolved issues with dependencies
* 2017-04-30   v1.0.13  Added websocket (i.e. method callbacks)
* 2017-05-03   v1.0.14  Backward compatibility for mockAnyResponse

---

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mockserver-client",
"version": "1.0.13",
"version": "1.0.14",
"homepage": "https://github.com/jamesdbloom/mockserver-client-node",
"authors": [
"James Bloom <jamesdbloom@gmail.com>"
Expand Down
10 changes: 5 additions & 5 deletions mockServerClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ var mockServerClient;
* Setup an expectation in the MockServer by specifying an expectation object
* for example:
*
* mockServerClient("localhost", 1080).mockAnyExpectation(
* mockServerClient("localhost", 1080).mockAnyResponse(
* {
* 'httpRequest': {
* 'path': '/somePath',
Expand All @@ -239,7 +239,7 @@ var mockServerClient;
*
* @param expectation the expectation to setup on the MockServer
*/
var mockAnyExpectation = function (expectation) {
var mockAnyResponse = function (expectation) {
if (expectation.httpRequest.headers) {
expectation.httpRequest.headers = arrayUniqueConcatenate(expectation.httpRequest.headers, defaultRequestHeaders);
} else if (expectation.httpRequest) {
Expand Down Expand Up @@ -314,13 +314,13 @@ var mockServerClient;
* @param statusCode the response code to return if a request matches
*/
var mockSimpleResponse = function (path, responseBody, statusCode) {
return mockAnyExpectation(createExpectation(path, responseBody, statusCode));
return mockAnyResponse(createExpectation(path, responseBody, statusCode));
};
/**
* Override:
*
* - default headers that are used to specify the response headers in mockSimpleResponse(...)
* (note: if you use mockAnyExpectation(...) the default headers are not used)
* (note: if you use mockAnyResponse(...) the default headers are not used)
*
* - headers added to every request matcher, this is particularly useful for running tests in parallel
*
Expand Down Expand Up @@ -507,7 +507,7 @@ var mockServerClient;
};

var _this = {
mockAnyExpectation: mockAnyExpectation,
mockAnyResponse: mockAnyResponse,
mockWithCallback: mockWithCallback,
mockSimpleResponse: mockSimpleResponse,
setDefaultHeaders: setDefaultHeaders,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mockserver-client",
"description": "A node client for the MockServer",
"version": "1.0.13",
"version": "1.0.14",
"homepage": "https://github.com/jamesdbloom/mockserver",
"author": {
"name": "James Bloom",
Expand Down
26 changes: 13 additions & 13 deletions test/no_proxy/mock_server_browser_client_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w

it("should create full expectation with string body", function (done) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'method': 'POST',
Expand Down Expand Up @@ -123,7 +123,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w

it("should match on method only", function (done) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'method': 'GET'
Expand All @@ -143,7 +143,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'method': 'POST'
Expand Down Expand Up @@ -198,7 +198,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w

it("should match on path only", function (done) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'path': '/firstPath'
Expand All @@ -218,7 +218,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'path': '/secondPath'
Expand Down Expand Up @@ -273,7 +273,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w

it("should match on query string parameters only", function (done) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'queryStringParameters': [
Expand All @@ -298,7 +298,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'queryStringParameters': [
Expand Down Expand Up @@ -358,7 +358,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w

it("should match on body only", function (done) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'body': {
Expand All @@ -381,7 +381,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'body': {
Expand Down Expand Up @@ -439,7 +439,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w

it("should match on headers only", function (done) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'headers': [
Expand All @@ -464,7 +464,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'headers': [
Expand Down Expand Up @@ -531,7 +531,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w
// need to add extra support for CORS to enable this
xit("should match on cookies only", function (done) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'cookies': [
Expand All @@ -556,7 +556,7 @@ if ((typeof __karma__ !== 'undefined' ? __karma__.config.mode === 'no_proxy' : w
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'cookies': [
Expand Down
26 changes: 13 additions & 13 deletions test/no_proxy/mock_server_node_client_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

'should create full expectation with string body': function (test) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'method': 'POST',
Expand Down Expand Up @@ -159,7 +159,7 @@

'should match on method only': function (test) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'method': 'GET'
Expand All @@ -179,7 +179,7 @@
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'method': 'POST'
Expand Down Expand Up @@ -245,7 +245,7 @@

'should match on path only': function (test) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'path': '/firstPath'
Expand All @@ -265,7 +265,7 @@
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'path': '/secondPath'
Expand Down Expand Up @@ -331,7 +331,7 @@

'should match on query string parameters only': function (test) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'queryStringParameters': [
Expand All @@ -356,7 +356,7 @@
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'queryStringParameters': [
Expand Down Expand Up @@ -427,7 +427,7 @@

'should match on body only': function (test) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'body': {
Expand All @@ -450,7 +450,7 @@
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'body': {
Expand Down Expand Up @@ -519,7 +519,7 @@

'should match on headers only': function (test) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'headers': [
Expand All @@ -544,7 +544,7 @@
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'headers': [
Expand Down Expand Up @@ -615,7 +615,7 @@

'should match on cookies only': function (test) {
// when
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'cookies': [
Expand All @@ -640,7 +640,7 @@
}
).then(function () {
// and - another expectation
client.mockAnyExpectation(
client.mockAnyResponse(
{
'httpRequest': {
'cookies': [
Expand Down

0 comments on commit db9cae9

Please sign in to comment.