60 lines
1.2 KiB
Text
60 lines
1.2 KiB
Text
meta {
|
|
name: Signup
|
|
type: http
|
|
seq: 1
|
|
}
|
|
|
|
post {
|
|
url: {{baseUrl}}/signup
|
|
body: json
|
|
auth: none
|
|
}
|
|
|
|
headers {
|
|
Content-Type: application/json
|
|
}
|
|
|
|
body:json {
|
|
{
|
|
"user": {
|
|
"name": "Test User",
|
|
"email": "test@example.com",
|
|
"password": "password123",
|
|
"password_confirmation": "password123"
|
|
}
|
|
}
|
|
}
|
|
|
|
assert {
|
|
res.status: equals 200
|
|
}
|
|
|
|
script:post-response {
|
|
const body = res.getBody();
|
|
if (body && body.data && body.data.token) {
|
|
bru.setVar("authToken", body.data.token);
|
|
bru.setVar("userId", body.data.user.id);
|
|
bru.setVar("userEmail", "test@example.com");
|
|
}
|
|
}
|
|
|
|
tests {
|
|
test("Signup returns wrapped success response", function() {
|
|
const data = res.getBody();
|
|
expect(data).to.have.property("success");
|
|
expect(data.success).to.equal(true);
|
|
});
|
|
|
|
test("Signup response contains data envelope", function() {
|
|
const data = res.getBody();
|
|
expect(data).to.have.property("data");
|
|
});
|
|
|
|
test("Data contains user and token", function() {
|
|
const data = res.getBody();
|
|
expect(data.data).to.have.property("user");
|
|
expect(data.data).to.have.property("token");
|
|
expect(data.data.user).to.have.property("id");
|
|
expect(data.data.user).to.have.property("email");
|
|
});
|
|
}
|