mirror of
https://github.com/status-im/github-comment-manager.git
synced 2025-02-19 20:58:09 +00:00
add tests for postComment
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
23299203e5
commit
08de6dcf2b
5
.babelrc
5
.babelrc
@ -1,4 +1,9 @@
|
||||
{
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": [ "istanbul" ]
|
||||
}
|
||||
},
|
||||
"presets": [
|
||||
["@babel/env", { "targets": {"node": "current"} }]
|
||||
],
|
||||
|
10
package.json
10
package.json
@ -23,6 +23,7 @@
|
||||
"@babel/plugin-transform-async-to-generator": "^7.1.0",
|
||||
"@babel/preset-env": "^7.1.0",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"babel-plugin-istanbul": "^5.1.0",
|
||||
"chai": "^4.2.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"gulp": "^3.9.1",
|
||||
@ -32,19 +33,28 @@
|
||||
"gulp-print": "^5.0.0",
|
||||
"mocha": "^5.2.0",
|
||||
"nodemon": "^1.18.4",
|
||||
"nyc": "^13.1.0",
|
||||
"sinon": "^7.1.1",
|
||||
"sinon-chai": "^3.3.0",
|
||||
"supertest": "^3.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"test": "mocha --require @babel/register",
|
||||
"testw": "mocha --require @babel/register --watch",
|
||||
"cover": "nyc mocha",
|
||||
"devel": "gulp devel",
|
||||
"clean": "gulp clean",
|
||||
"build": "gulp build",
|
||||
"image": "docker build -t statusteam/ghcmgr .",
|
||||
"push": "docker push statusteam/ghcmgr"
|
||||
},
|
||||
"mocha": [
|
||||
"@babel/register"
|
||||
],
|
||||
"require": [
|
||||
"@babel/register"
|
||||
],
|
||||
"keywords": [
|
||||
"github",
|
||||
"comments",
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import Octokit from '@octokit/rest'
|
||||
|
||||
import Builds from '../src/builds'
|
||||
import Comments from '../src/comments'
|
||||
@ -42,7 +41,12 @@ const COMMENT = `
|
||||
|
||||
describe('Comments', () => {
|
||||
beforeEach(() => {
|
||||
//client = sinon.createStubInstance(Octokit, {what: 2})
|
||||
client = {
|
||||
issues: {
|
||||
createComment: sinon.stub().returns({ data: { id: 'ISSUE-ID' }}),
|
||||
updateComment: sinon.stub().returns({ data: { id: 'ISSUE-ID' }}),
|
||||
},
|
||||
}
|
||||
builds = sinon.createStubInstance(Builds, {
|
||||
getBuilds: BUILDS,
|
||||
})
|
||||
@ -64,4 +68,17 @@ describe('Comments', () => {
|
||||
expect(body).to.eq(COMMENT)
|
||||
})
|
||||
})
|
||||
|
||||
describe('postComment', () => {
|
||||
it('should create a new comment', async () => {
|
||||
let id = await comments.postComment('PR')
|
||||
expect(id).to.eq('ISSUE-ID')
|
||||
expect(client.issues.createComment).calledOnceWith({
|
||||
body: sinon.match.any,
|
||||
number: 'PR',
|
||||
owner: 'owner',
|
||||
repo: 'repo',
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
4
test/setup.js
Normal file
4
test/setup.js
Normal file
@ -0,0 +1,4 @@
|
||||
import chai from 'chai'
|
||||
import sinonChai from 'sinon-chai'
|
||||
|
||||
chai.use(sinonChai)
|
Loading…
x
Reference in New Issue
Block a user