-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
divramod
committed
Jul 19, 2016
1 parent
7544f4b
commit e7c779b
Showing
10 changed files
with
88 additions
and
93 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,18 @@ describe("UserRepository", function() { | |
|
||
it("Authenticate a User", function(done) { | ||
const userController = new UserController(server, new UserRepository()); | ||
userController.authenticate().then((user) => { | ||
console.log(user); | ||
const user = { | ||
'username': 'divramod', | ||
'name': 'Petermann', | ||
'forename': 'Arvid', | ||
'email': '[email protected]', | ||
'telefon': '017620158302' | ||
} | ||
userController.authenticate(user).then((user) => { | ||
//console.log(user); | ||
done(); | ||
}).catch((error) => { | ||
console.log(error); | ||
//console.log(error); | ||
done(error); | ||
}); | ||
}); | ||
|
@@ -31,6 +38,7 @@ describe("UserRepository", function() { | |
name: "teste", | ||
forename: "teste", | ||
email: "user", | ||
telefon: "017625322", | ||
createdDate: undefined, | ||
updatedAt: undefined | ||
}; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/// <reference path="../../typings/index.d.ts" /> | ||
import * as chai from "chai"; | ||
let assert = chai.assert; | ||
|
||
import server from "../../src/server"; | ||
import UserController from '../../src/controllers/userController'; | ||
import UserRepository from '../../src/libs/repository/mongo/userRepository'; | ||
import {IUser} from "../../src/libs/repository/interfaces"; | ||
|
||
describe("route user/create POST", function() { | ||
|
||
const userController = new UserController(server, new UserRepository()); | ||
|
||
it("should create a user", function(done) { | ||
let user: IUser = { | ||
'username': 'divramod', | ||
'name': 'Petermann', | ||
'forename': 'Arvid', | ||
'email': '[email protected]', | ||
'telefon': '017620158302' | ||
} | ||
const request = { | ||
method: 'POST', | ||
url: '/api/users', | ||
payload: user | ||
}; | ||
|
||
server.inject(request).then((response) => { | ||
let res = JSON.parse(response.payload); | ||
|
||
assert.strictEqual(user.email, res.email, 'email') | ||
assert.strictEqual(user.username, res.username, 'username') | ||
assert.strictEqual(user.name, res.name, 'name') | ||
assert.strictEqual(user.forename, res.forename, 'forename') | ||
assert.isNumber(res.telefon, 'telefon should be a number') | ||
|
||
assert.isString(res._id, '_id should be a string') | ||
assert.isDefined(res._id, '_id should be defined') | ||
assert.strictEqual(res._id.length, 36, 'lenght of id should be 36') | ||
assert.isDefined(res.createdDate, 'createdDate should be defined') | ||
done(); | ||
}).catch((error) => { | ||
console.log(error); | ||
}); | ||
|
||
}); | ||
}); |