Skip to content

Commit

Permalink
Ava snapshots (#16)
Browse files Browse the repository at this point in the history
* Implemented to use Ava snapshots for the "int" test for easier maintenance of the tests.

* Formatted code

Co-authored-by: Tim <>
  • Loading branch information
thim81 authored Aug 19, 2021
1 parent 17f5235 commit 9da1858
Show file tree
Hide file tree
Showing 21 changed files with 2,019 additions and 1,775 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"ecmaVersion": 8
},
"rules": {
"semi": "error",
"semi": [2, "always"],
"space-before-function-paren": ["error", "never"]
}
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/apideck-libraries/postman-to-k6/compare/v1.6.0...HEAD)

### Changed

- Updated readme
- Migrated the "integration" tests to use Ava snapshots instead of the hardcoded comparison for easier maintenance

## [1.6.1] - 2020-08-18

### Fixed
Expand Down
31 changes: 16 additions & 15 deletions test/com/shim/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import test from 'ava';
import mockRequire from 'mock-require';

let k6, http;

const Reset = Symbol.for('reset');
Expand All @@ -29,7 +30,7 @@ test.serial('responseCookies', t => {
name: 'Theme',
path: '/',
secure: false,
value: 'Aqua'
value: 'Aqua',
};
http.request.returns({ cookies: { Theme: [cookie] } });
postman[Request]({
Expand All @@ -39,7 +40,7 @@ test.serial('responseCookies', t => {
for (const key of Object.keys(cookie)) {
t.is(responseCookie[key], cookie[key]);
}
}
},
});
});

Expand All @@ -51,7 +52,7 @@ test.serial('cookie.hostOnly', t => {
/* eslint-disable-next-line no-unused-expressions */
responseCookies[0].hostOnly;
});
}
},
});
});

Expand All @@ -63,7 +64,7 @@ test.serial('cookie.session', t => {
/* eslint-disable-next-line no-unused-expressions */
responseCookies[0].session;
});
}
},
});
});

Expand All @@ -75,7 +76,7 @@ test.serial('cookie.storeId', t => {
/* eslint-disable-next-line no-unused-expressions */
responseCookies[0].storeId;
});
}
},
});
});

Expand All @@ -86,7 +87,7 @@ test.serial('postman.getResponseCookie', t => {
name: 'Theme',
path: '/',
secure: false,
value: 'Aqua'
value: 'Aqua',
};
http.request.returns({ cookies: { Theme: [cookie] } });
postman[Request]({
Expand All @@ -96,15 +97,15 @@ test.serial('postman.getResponseCookie', t => {
for (const key of Object.keys(cookie)) {
t.is(responseCookie[key], cookie[key]);
}
}
},
});
});

test.serial('pm.cookies.get clear', t => {
postman[Request]({
post() {
t.is(pm.cookies.get('Theme'), null);
}
},
});
});

Expand All @@ -114,15 +115,15 @@ test.serial('pm.cookies.get set', t => {
postman[Request]({
post() {
t.is(pm.cookies.get('Theme'), 'Aqua');
}
},
});
});

test.serial('pm.cookies.has clear', t => {
postman[Request]({
post() {
t.false(pm.cookies.has('Theme'));
}
},
});
});

Expand All @@ -131,23 +132,23 @@ test.serial('pm.cookies.has set', t => {
postman[Request]({
post() {
t.true(pm.cookies.has('Theme'));
}
},
});
});

test.serial('pm.cookies.toObject', t => {
http.request.returns({
cookies: {
Theme: [{ name: 'Theme', value: 'Aqua' }],
Session: [{ name: 'Session', value: 'abc123' }]
}
Session: [{ name: 'Session', value: 'abc123' }],
},
});
postman[Request]({
post() {
t.deepEqual(pm.cookies.toObject(), {
Theme: 'Aqua',
Session: 'abc123'
Session: 'abc123',
});
}
},
});
});
Loading

0 comments on commit 9da1858

Please sign in to comment.