Skip to content

Commit

Permalink
Fixing mock priority ordering.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tynarus committed Sep 16, 2019
1 parent 1d80757 commit 8f4e086
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/mock-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ export function start(port = 4300) {

if(foundMatch) {
fullyMatchingMocks.push(checkMock);
break;
}
}

Expand Down
42 changes: 42 additions & 0 deletions src/test-mock-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,46 @@ mock({
}
});

mock({
priority: 1,
method: 'POST',
url: '/test',
requestBody: {
testValue1: 'hello',
testValue2: 'world'
},
responseStatus: 200,
responseBody: {
text: 'Hello world!'
}
});

mock({
priority: 2,
method: 'POST',
url: '/test',
requestBody: {
testValue1: /^(.*)$/,
testValue2: /^(.*)$/
},
responseStatus: 401,
responseBody: {
text: 'Unauthorized'
}
});

mock({
priority: 1,
method: 'POST',
url: '/test',
requestBody: {
testValue1: 'big',
testValue2: 'boss'
},
responseStatus: 200,
responseBody: {
text: 'Hello world!'
}
});

start();

0 comments on commit 8f4e086

Please sign in to comment.