-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/databaseMigration
- Loading branch information
Showing
11 changed files
with
580 additions
and
92 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ module.exports = { | |
* @param queryInterface, Sequelize | ||
*/ | ||
return queryInterface.bulkInsert('Users', [{ | ||
id: 1, | ||
username: 'vvidaapp', | ||
name:'vvida lavida', | ||
password: bcrypt.hashSync('[email protected]'), | ||
gender: 'Female', | ||
email: '[email protected]', | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
var request = require('superagent'), | ||
faker = require('faker'), | ||
_expect = require('expect.js'), | ||
resourceApiUrl = 'http://localhost:3000/api/categories'; | ||
|
||
describe('Categories resource API tests', function() { | ||
|
||
var generateFakeCategory = function() { | ||
return { | ||
// catId: faker.random.number(), | ||
name: faker.commerce.department(), | ||
category: 'Item' | ||
}; | ||
}, | ||
authToken = null, | ||
// id to be a 'string'when a resource added | ||
id; | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* POST /user/login | ||
* | ||
* @return Response | ||
*/ | ||
it('Must create session to be able to run actions on items', function(done) { | ||
// Must log in to retain a session | ||
request | ||
.post('http://localhost:3000/api/users/login') | ||
.send({ | ||
email: '[email protected]', | ||
password: '[email protected]' | ||
}) | ||
.end(function(err, res) { | ||
_expect(res.status).to.be(200); | ||
_expect(res.body.token).to.be.a('string'); | ||
_expect(res.body.token.length).to.be.greaterThan(100); | ||
authToken = res.body.token; | ||
done(); | ||
}); | ||
}); | ||
|
||
/** | ||
* Display a listing of the resource. | ||
* GET /categories | ||
* | ||
* @return Response | ||
*/ | ||
|
||
it('should return empty array if DB is empty', function(done) { | ||
request | ||
.get(resourceApiUrl) | ||
.accept('application/json') | ||
.end(function(err, res) { | ||
_expect(res.status).to.be(200); | ||
_expect(res.body).to.be.an(Array); | ||
done(); | ||
}); | ||
}); | ||
|
||
|
||
it('should not store a newly created resource in storage.', function(done) { | ||
var category = generateFakeCategory(); | ||
request | ||
.post(resourceApiUrl) | ||
.send(category) | ||
.accept('application/json') | ||
.end(function(err, res) { | ||
_expect(res.status).to.be(500); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should store a newly created resource in storage.', function(done) { | ||
var category = generateFakeCategory(); | ||
request | ||
.post(resourceApiUrl) | ||
.set('X-Access-Token', authToken) | ||
.send(category) | ||
.accept('application/json') | ||
.end(function(err, res) { | ||
_expect(res.status).to.be(200); | ||
var newCategory = res.body; | ||
_expect(newCategory.type).to.be(category.category); | ||
_expect(newCategory.id).to.be.a('number'); | ||
id = newCategory.id; | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should return all categories', function(done) { | ||
request | ||
.get(resourceApiUrl) | ||
.query({ | ||
'type': 'Item' | ||
}) | ||
.accept('application/json') | ||
.end(function(err, res) { | ||
_expect(res.status).to.be(200); | ||
var category = res.body; | ||
_expect(category.length).to.be.greaterThan(0); | ||
_expect(category[0].id).to.be.a('number'); | ||
_expect(category[0].type).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
|
||
|
||
/** | ||
* Show the form for creating the specified resource. | ||
* GET /categories/:id | ||
* | ||
* @param int $id | ||
* @return Response | ||
*/ | ||
it('should show the form for creating a new resource', function() { | ||
// Not used in an angular application | ||
// since the angular application will route to the edit form | ||
// and display it | ||
_expect(true).to.be(true); | ||
}); | ||
|
||
/** | ||
* Display the specified resource. | ||
* GET /categories/{id} | ||
* | ||
* @param int $id | ||
* @return Response | ||
*/ | ||
it('should display the specified resource.', function(done) { | ||
request | ||
.get(resourceApiUrl + '/' + id) | ||
.query({ | ||
'model': 'Items' | ||
}) | ||
.accept('application/json') | ||
.end(function(err, res) { | ||
_expect(res.status).to.be(200); | ||
_expect(res.body.id).to.be(id); | ||
done(); | ||
}); | ||
}); | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* DELETE /categories/:id | ||
* | ||
* @param int $id | ||
* @return Response | ||
*/ | ||
it('should remove the specified resource from storage.', function(done) { | ||
request | ||
.del(resourceApiUrl + '/' + id) | ||
.set('X-Access-Token', authToken) | ||
.accept('application/json') | ||
.end(function(err, res) { | ||
_expect(res.status).to.be(200); | ||
_expect(res.body.message).to.match(/(success)/); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should assert the document was deleted.', function(done) { | ||
request | ||
.get(resourceApiUrl + '/' + id) | ||
.query({ | ||
'model': 'Items' | ||
}) | ||
.accept('application/json') | ||
.end(function(err, res) { | ||
_expect(res.status).to.be(200); | ||
_expect(res.body).to.be(null); | ||
done(); | ||
}); | ||
}); | ||
|
||
}); |
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,29 @@ | ||
var request = require('superagent'), | ||
_expect = require('expect.js'), | ||
resourceApiUrl = 'http://localhost:3000/api/countries'; | ||
|
||
describe('Countries resource API tests', function() { | ||
|
||
/** | ||
* Display a listing of the resource. | ||
* GET /countries | ||
* | ||
* @return Response | ||
*/ | ||
it('should return countries or empty array if DB is empty', function(done) { | ||
request | ||
.get(resourceApiUrl) | ||
.accept('application/json') | ||
.end(function(err, res) { | ||
_expect(res.status).to.be(200); | ||
if (res.body.length === 0) { | ||
_expect(res.body).to.be.an('array'); | ||
} else { | ||
var country = res.body; | ||
_expect(country.length).to.be.greaterThan(0); | ||
_expect(country[0].name).to.be.a('string'); | ||
} | ||
done(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.