Skip to content

Commit

Permalink
Add more unit tests (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewturner authored Sep 8, 2024
1 parent 01158b8 commit ffb82c9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/tests/RequestDefinitionBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,33 @@ describe('Request Definition Builder', () => {
expect(actual).toBe('\n\n?? status == 200');
});

test('Id from response is set as global variable', () => {
getRequest.events.clear();

const event1 = new Event({
listen: 'test', script: {
exec:
[
"pm.test(\"Status test\", function () {\r",
" pm.environment.set(\"someId\", pm.response.json().id);\r",
"});"
]
}
});
getRequest.events.add(event1);

const target = new RequestDefinitionBuilder()
.from(getRequest)
.appendTestScript();

const actual = target.toString();

expect(actual).toBe('\n\n{{'
+ '\n $global.someId = response.parsedBody.id;'
+ '\n}}'
);
});

test('Unknown test script is added commented out', () => {
getRequest.events.clear();

Expand Down

0 comments on commit ffb82c9

Please sign in to comment.