-
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.
feature(share-articles): Users should be able to share articles acros…
…s different channels [Finishes #167313416]
- Loading branch information
1 parent
883dce9
commit 45cf47f
Showing
4 changed files
with
98 additions
and
11 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,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
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); | ||
}); | ||
}); |