-
Notifications
You must be signed in to change notification settings - Fork 7
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
10 changed files
with
217 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import open from 'open'; | ||
|
||
const openUrl = url => open(url); | ||
|
||
const OpenUrlHelper = { openUrl }; | ||
|
||
export default OpenUrlHelper; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
// import { chai, server, expect } from './test-setup'; | ||
// import Helper from '../src/helpers/helper'; | ||
import { chai, server, expect } from './test-setup'; | ||
import Helper from '../src/helpers/helper'; | ||
|
||
// const usertoken = Helper.generateToken({ | ||
// id: 2, | ||
// email: 'user@gmail.com', | ||
// username: 'user', | ||
// verified: false | ||
// }); | ||
const usertoken = Helper.generateToken({ | ||
id: 2, | ||
email: 'user@gmail.com', | ||
username: 'user', | ||
verified: false | ||
}); | ||
|
||
// describe('search article query builder', () => { | ||
// it('List of all articles', (done) => { | ||
// chai | ||
// .request(server) | ||
// .get('/api/v1/articles') | ||
// .set('Content-Type', 'application/json') | ||
// .set('Authorization', usertoken) | ||
// .end((err, res) => { | ||
// expect(res.status).to.be.deep.equal(200); | ||
// expect(res.body).to.have.deep.property('message', 'List of all articles'); | ||
// }); | ||
// done(); | ||
// }); | ||
// it('Title and description in the query', (done) => { | ||
// chai | ||
// .request(server) | ||
// .get('/api/v1/articles?title=Title&&keyword=here') | ||
// .set('Content-Type', 'application/json') | ||
// .set('Authorization', usertoken) | ||
// .end((err, res) => { | ||
// if (err) done(err); | ||
// expect(res.status).to.be.deep.equal(200); | ||
// expect(res.body).to.have.deep.property('message', 'List of all articles'); | ||
// }); | ||
// done(); | ||
// }); | ||
// it('if invalid query key', (done) => { | ||
// chai | ||
// .request(server) | ||
// .get('/api/v1/articles?key=Tilltle') | ||
// .set('Content-Type', 'application/json') | ||
// .set('Authorization', usertoken) | ||
// .end((err, res) => { | ||
// if (err) done(err); | ||
// expect(res.status).to.be.deep.equal(400); | ||
// expect(res.body).to.have.deep.property('error'); | ||
// }); | ||
// done(); | ||
// }); | ||
// }); | ||
describe('search article query builder', () => { | ||
it('List of all articles', (done) => { | ||
chai | ||
.request(server) | ||
.get('/api/v1/articles') | ||
.set('Content-Type', 'application/json') | ||
.set('Authorization', usertoken) | ||
.end((err, res) => { | ||
expect(res.status).to.be.deep.equal(200); | ||
expect(res.body).to.have.deep.property('message', 'List of all articles'); | ||
done(); | ||
}); | ||
}); | ||
it('Title and description in the query', (done) => { | ||
chai | ||
.request(server) | ||
.get('/api/v1/articles?title=Title&&keyword=here') | ||
.set('Content-Type', 'application/json') | ||
.set('Authorization', usertoken) | ||
.end((err, res) => { | ||
if (err) done(err); | ||
expect(res.status).to.be.deep.equal(200); | ||
expect(res.body).to.have.deep.property('message', 'List of all articles'); | ||
done(); | ||
}); | ||
}); | ||
it('if invalid query key', (done) => { | ||
chai | ||
.request(server) | ||
.get('/api/v1/articles?key=Tilltle') | ||
.set('Content-Type', 'application/json') | ||
.set('Authorization', usertoken) | ||
.end((err, res) => { | ||
if (err) done(err); | ||
expect(res.status).to.be.deep.equal(400); | ||
expect(res.body).to.have.deep.property('error'); | ||
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,56 @@ | ||
import sinon from 'sinon'; | ||
import { expect } from './test-setup'; | ||
import Article from '../src/controllers/articles.controller'; | ||
import OpenUrlHelper from '../src/helpers/share.article.helper'; | ||
|
||
describe('test for sharing an article', () => { | ||
it('test for sharing an article via facebook', async () => { | ||
const req = { | ||
params: { slug: 'fakeslug', channel: 'facebook' }, | ||
auth: { | ||
email: 'user@gmail.com' | ||
} | ||
}; | ||
const res = { | ||
status() { }, | ||
send() { }, | ||
json() { } | ||
}; | ||
sinon.stub(res, 'status').returnsThis(); | ||
sinon.stub(OpenUrlHelper, 'openUrl').returns(true); | ||
await Article.shareArticle(req, res); | ||
expect(res.status).to.have.been.calledWith(200); | ||
}); | ||
it('test for sharing an article via twitter', async () => { | ||
const req = { | ||
params: { slug: 'fakeslug', channel: 'twitter' }, | ||
auth: { | ||
email: 'user@gmail.com' | ||
} | ||
}; | ||
const res = { | ||
status() { }, | ||
send() { }, | ||
json() { } | ||
}; | ||
sinon.stub(res, 'status').returnsThis(); | ||
await Article.shareArticle(req, res); | ||
expect(res.status).to.have.been.calledWith(200); | ||
}); | ||
it('test for sharing an article via mail', async () => { | ||
const req = { | ||
params: { slug: 'fakeslug', channel: 'twitter' }, | ||
auth: { | ||
email: 'user@gmail.com' | ||
} | ||
}; | ||
const res = { | ||
status() { }, | ||
send() { }, | ||
json() { } | ||
}; | ||
sinon.stub(res, 'status').returnsThis(); | ||
await Article.shareArticle(req, res); | ||
expect(res.status).to.have.been.calledWith(200); | ||
}); | ||
}); |
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