Skip to content

Commit a31b9a7

Browse files
committed
fetch and create steps for objects acceptance tests
1 parent 23493d7 commit a31b9a7

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Given, When, Then } from '@cucumber/cucumber';
2+
import { expect } from 'chai';
3+
4+
Given('the user ID {string}, name {string}', async function(userId, userName) {
5+
// remember the channel we subscribed to
6+
this.userId = userId;
7+
this.userName = userName;
8+
});
9+
10+
When('I create the user', async function() {
11+
let pubnub = this.getPubnub({
12+
publishKey: this.keyset.publishKey,
13+
subscribeKey: this.keyset.subscribeKey
14+
});
15+
16+
let result = await pubnub.createUser({
17+
userId: this.userId,
18+
data: {
19+
name: this.userName
20+
}
21+
});
22+
expect(result.status).to.equal(200);
23+
this.user = result.data;
24+
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { Given, When, Then } from '@cucumber/cucumber';
2+
import { expect } from 'chai';
3+
4+
Given('there is a user with ID {string}, name {string}', async function(userId, userName) {
5+
// remember the channel we subscribed to
6+
this.userId = userId;
7+
this.userName = userName;
8+
});
9+
10+
When('I fetch the user {string}', async function(userId) {
11+
// ensure we fetch the existing specified user id
12+
expect(userId).to.equal(this.userId);
13+
14+
let pubnub = this.getPubnub({
15+
publishKey: this.keyset.publishKey,
16+
subscribeKey: this.keyset.subscribeKey
17+
});
18+
19+
let result = await pubnub.fetchUser({
20+
userId: userId
21+
});
22+
expect(result.status).to.equal(200);
23+
this.user = result.data;
24+
});
25+
26+
When('I fetch all users', async function() {
27+
let pubnub = this.getPubnub({
28+
publishKey: this.keyset.publishKey,
29+
subscribeKey: this.keyset.subscribeKey
30+
});
31+
32+
let result = await pubnub.fetchUsers();
33+
expect(result.status).to.equal(200);
34+
this.users = result.data;
35+
});
36+
37+
Then('I get a list of user objects', async function() {
38+
expect(this.users).to.not.be.undefined;
39+
40+
this.user = this.users[0];
41+
});
42+
43+
Then('I get a user object with', async function() {
44+
expect(this.user).to.not.be.undefined;
45+
});
46+
47+
Then('ID equal to {string}', async function(userId) {
48+
expect(userId).to.equal(this.user.id);
49+
});
50+
51+
Then('Name equal to {string}', async function(userName) {
52+
expect(userName).to.equal(this.user.name);
53+
});

0 commit comments

Comments
 (0)