forked from cypress-io/cypress-realworld-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api-banktransfers.spec.ts
36 lines (28 loc) · 992 Bytes
/
api-banktransfers.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { User } from "../../../src/models";
const apiBankTransfer = `${Cypress.env("apiUrl")}/bankTransfers`;
type TestBankTransferCtx = {
authenticatedUser?: User;
};
describe("Bank Transfer API", function () {
let ctx: TestBankTransferCtx = {};
before(() => {
// Hacky workaround to have the e2e tests pass when cy.visit('http://localhost:3000') is called
cy.request("GET", "/");
});
beforeEach(function () {
cy.task("db:seed");
cy.database("find", "users").then((user: User) => {
ctx.authenticatedUser = user;
return cy.loginByApi(ctx.authenticatedUser.username);
});
});
context("GET /bankTransfer", function () {
it("gets a list of bank transfers for user", function () {
const { id: userId } = ctx.authenticatedUser!;
cy.request("GET", `${apiBankTransfer}`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.transfers[0].userId).to.eq(userId);
});
});
});
});