-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
7 changed files
with
78 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable no-unused-vars */ | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('articles', { | ||
id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true }, | ||
slug: { type: Sequelize.STRING, allowNull: false, unique: true }, | ||
title: { type: Sequelize.STRING, required: true }, | ||
description: { type: Sequelize.TEXT, allowNull: true }, | ||
body: { type: Sequelize.TEXT, required: true }, | ||
taglist: { type: Sequelize.ARRAY(Sequelize.STRING), defaultValue: [] }, | ||
authorid: { type: Sequelize.INTEGER, allowNull: false }, | ||
createdAt: { allowNull: false, type: Sequelize.DATE }, | ||
updatedAt: { allowNull: false, type: Sequelize.DATE }, | ||
}), | ||
down: (queryInterface, Sequelize) => queryInterface.dropTable('articles') | ||
}; |
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,13 @@ | ||
module.exports = (sequelize, DataTypes) => { | ||
const Article = sequelize.define('article', { | ||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true }, | ||
slug: { type: DataTypes.STRING, allowNull: false, unique: true }, | ||
title: { type: DataTypes.STRING, allowNull: false }, | ||
body: { type: DataTypes.TEXT, allowNull: false }, | ||
taglist: { type: DataTypes.ARRAY(DataTypes.STRING), allowNull: true }, | ||
description: { type: DataTypes.TEXT, allowNull: true }, | ||
authorid: { type: DataTypes.INTEGER, allowNull: false } | ||
}, {}); | ||
|
||
return Article; | ||
}; |
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,11 @@ | ||
import express from 'express'; | ||
|
||
const router = express.Router(); | ||
|
||
router.post('/'); | ||
router.get('/'); | ||
router.delete('/:slug'); | ||
router.put('/:slug'); | ||
|
||
|
||
export default router; |
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,21 @@ | ||
import chai from 'chai'; | ||
import chaiHttp from 'chai-http'; | ||
import index from '../index'; | ||
|
||
chai.should(); | ||
chai.use(chaiHttp); | ||
|
||
/** | ||
* @author: Innocent Nkunzi | ||
* @description: tests related to article | ||
*/ | ||
describe('Test the home route', () => { | ||
it('should return the landing page', (done) => { | ||
chai.request(index).get('/').then((res) => { | ||
res.should.have.status(200); | ||
res.body.should.have.property('message').eql('Welcome to Author Haven'); | ||
done(); | ||
}) | ||
.catch(err => err); | ||
}); | ||
}); |
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,8 @@ | ||
import faker from 'faker'; | ||
|
||
module.exports = { | ||
title: faker.random.words(), | ||
description: faker.lorem.sentences(), | ||
body: faker.lorem.sentences(), | ||
authorid: faker.random.number(), | ||
}; |