Skip to content

Commit

Permalink
improves users specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Miguel Gallas Olmedo authored and Jose Miguel Gallas Olmedo committed Jul 21, 2017
1 parent 15738c0 commit 2617478
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions spec/routes/users.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,24 @@ describe("Route users", () => {
const newUser: User = JSON.parse(JSON.stringify(TEST_USER));
newUser.username = "newUser";

it("returns 201 if the user is succesfully created", done => {
it("returns 201 if the user is succesfully created", async done => {
RealmHelper.deleteUser(newUser.username);

await Sleep.millis(200);

const user: User = RealmHelper.getUserByUsername(newUser.username);
expect(user).toBeFalsy();

ApiTestClient
.createUser(newUser)
.then(res => {
.then(async res => {
expect(res.statusCode).toEqual(201);

await Sleep.millis(200);

const createdUser: User = RealmHelper.getUserByUsername(newUser.username);
expect(createdUser).toBeTruthy();

done();
})
.catch(err => {
Expand Down Expand Up @@ -433,9 +444,11 @@ describe("Route users", () => {

ApiTestClient
.updateUser(userToUpdate)
.then(res => {
.then(async res => {
expect(res.statusCode).toEqual(200);

await Sleep.millis(200);

const userAfterUpdating: User = RealmHelper.getUserByUsername(userToUpdate.username);
expect(userAfterUpdating.email).toEqual(userToUpdate.email);

Expand All @@ -462,9 +475,11 @@ describe("Route users", () => {

ApiTestClient
.updateUser(userToUpdate)
.then(res => {
.then(async res => {
expect(res.statusCode).toEqual(200);

await Sleep.millis(200);

const userAfterUpdating: User = RealmHelper.getUserByUsername(userToUpdate.username);
expect(userAfterUpdating.location.city).toEqual(userToUpdate.location.city);

Expand Down

0 comments on commit 2617478

Please sign in to comment.