add tests using mocha and chai
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
e0514c10a6
commit
27da010e8a
36
package.json
36
package.json
|
@ -23,50 +23,34 @@
|
|||
"@babel/plugin-transform-async-to-generator": "^7.1.0",
|
||||
"@babel/preset-env": "^7.1.0",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"chai": "^4.2.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-babel": "^8.0.0-beta.2",
|
||||
"gulp-clean": "^0.4.0",
|
||||
"gulp-nodemon": "^2.2.1",
|
||||
"gulp-print": "^5.0.0",
|
||||
"jest": "^23.6.0",
|
||||
"mocha": "^5.2.0",
|
||||
"nodemon": "^1.18.4",
|
||||
"sinon": "^7.1.1",
|
||||
"supertest": "^3.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"test": "jest",
|
||||
"testw": "jest --watchAll",
|
||||
"test": "mocha --require @babel/register",
|
||||
"testw": "mocha --require @babel/register --watch",
|
||||
"devel": "gulp devel",
|
||||
"clean": "gulp clean",
|
||||
"build": "gulp build",
|
||||
"image": "docker build -t statusteam/ghcmgr .",
|
||||
"push": "docker push statusteam/ghcmgr"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json"
|
||||
"keywords": [
|
||||
"github",
|
||||
"comments",
|
||||
"ci",
|
||||
"builds"
|
||||
],
|
||||
"collectCoverage": true,
|
||||
"collectCoverageFrom": [
|
||||
"src/**/*.js",
|
||||
"!**/node_modules/**",
|
||||
"!**/build/**",
|
||||
"!**/coverage/**"
|
||||
],
|
||||
"coverageReporters": [
|
||||
"text",
|
||||
"text-summary"
|
||||
],
|
||||
"testRegex": "/test/.*.js$",
|
||||
"testPathIgnorePatterns": [
|
||||
"/node_modules/",
|
||||
"/build/",
|
||||
"/coverage/"
|
||||
]
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class Builds {
|
|||
async getBuilds (pr) {
|
||||
const builds = await this.builds.chain()
|
||||
.find({pr})
|
||||
.compoundsort(['$loki', 'platform', 'id'])
|
||||
.compoundsort(['$loki', 'id'])
|
||||
.data()
|
||||
/* strip the $loki attribute */
|
||||
return builds.map((b) => {
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import Octokit from '@octokit/rest'
|
||||
|
||||
import Builds from '../src/builds'
|
||||
import Comments from '../src/comments'
|
||||
|
||||
let comments, client, builds
|
||||
|
||||
describe('Comments', () => {
|
||||
before(() => {
|
||||
//client = sinon.createStubInstance(Octokit, {what: 2})
|
||||
builds = sinon.createStubInstance(Builds, {
|
||||
getBuilds: []
|
||||
})
|
||||
comments = new Comments(client, 'owner', 'repo', builds)
|
||||
})
|
||||
|
||||
describe('renderComment', () => {
|
||||
it('should fail with no builds', async () => {
|
||||
try {
|
||||
await comments.renderComment('PR')
|
||||
} catch(err) {
|
||||
expect(err.message).to.eq('No builds exist for this PR')
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue