Skip to content

Commit

Permalink
chore(build): modify test scripts to fix build
Browse files Browse the repository at this point in the history
- ensure that builds are passing

[Finishes #164458431]
  • Loading branch information
Chrismarcel committed Mar 7, 2019
1 parent 11e9902 commit 1e2625b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"start": " node ./dist/app.js",
"dev": "nodemon --exec babel-node ./server/app.js",
"test": "npm run reset:db && nyc mocha --require @babel/polyfill --require @babel/register ./server/test/ --timeout 10000 --exit",
"test": "npm run reset:db && nyc mocha --require @babel/polyfill --require @babel/register ./server/test/index.js --timeout 10000 --exit",
"sequelize": "./node_modules/.bin/babel-node ./node_modules/.bin/sequelize $*",
"migrate": "./node_modules/.bin/babel-node ./node_modules/.bin/sequelize db:migrate",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
Expand Down
17 changes: 10 additions & 7 deletions server/controllers/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,16 @@ class ArticleController {
*/
async getSingleArticle(req, res) {
const { slug } = req.params;
const article = await Article.findOne({
where: {
slug
}
});

response(res).success({ messages: article });
try {
const article = await Article.findOne({
where: {
slug
}
});
return response(res).success({ message: article });
} catch (error) {
return response(res).serverError({ errors: { server: ['database error'] } });
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions server/test/articles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,12 +441,11 @@ describe('GET single article /api/articles/:slug', () => {
it('should return 200 if article exists', (done) => {
chai
.request(app)
.get('/api/articles/the-second-article-3')
.get('/api/articles/this-is-an-article-1')
.end((err, res) => {
const { id } = res.body.messages;
const { title } = res.body.message;
expect(res.status).to.be.equal(200);
expect(id).to.be.equal(3);

expect(title).to.be.equal('This is an article');
done(err);
});
});
Expand Down
2 changes: 1 addition & 1 deletion server/test/comment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('POST comment /api/articles/:slug/comment', () => {

it('should create a new comment', (done) => {
chai.request(app)
.post('/api/articles/this-is-an-article-2/comment')
.post('/api/articles/this-is-an-article-1/comment')
.set('authorization', `Bearer ${userToken}`)
.send({
comment: 'This is a random comment'
Expand Down

0 comments on commit 1e2625b

Please sign in to comment.