Skip to content

Commit 38f0378

Browse files
authored
Refactored cucumber steps into separate files (#610)
no refs Refactored cucumber steps into separate files, grouped by either feature or functionality (for generic steps). `stepdefs.js` has been renamed to `index.js` and contains the hooks to execute as well as any global setup
1 parent 8aac3f2 commit 38f0378

19 files changed

+1773
-1696
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import assert from 'node:assert';
2+
3+
import { Then } from '@cucumber/cucumber';
4+
5+
Then('the response contains {string} account details', async function (name) {
6+
const responseJson = await this.response.clone().json();
7+
const actor = name === 'Our' ? this.actors.Us : this.actors[name];
8+
9+
assert.equal(responseJson.name, actor.name);
10+
assert.equal(responseJson.handle, actor.handle);
11+
assert.equal(responseJson.bio, actor.summary);
12+
assert.equal(responseJson.url, actor.url);
13+
assert.equal(responseJson.avatarUrl, actor.icon?.url || '');
14+
assert.equal(responseJson.bannerImageUrl, actor.image?.url || '');
15+
assert.equal(typeof responseJson.postCount, 'number');
16+
assert.equal(typeof responseJson.likedCount, 'number');
17+
assert.equal(typeof responseJson.followingCount, 'number');
18+
assert.equal(typeof responseJson.followerCount, 'number');
19+
assert.equal(typeof responseJson.followedByMe, 'boolean');
20+
assert.equal(typeof responseJson.followsMe, 'boolean');
21+
});
22+
23+
Then('the response contains the account details:', async function (data) {
24+
const responseJson = await this.response.clone().json();
25+
26+
for (const [key, value] of Object.entries(data.rowsHash())) {
27+
assert.equal(
28+
responseJson[key],
29+
value,
30+
`Expected ${key} to be "${value}" but got "${responseJson[key]}"`,
31+
);
32+
}
33+
});

0 commit comments

Comments
 (0)