add tests using mocha and chai
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
e0514c10a6
commit
27da010e8a
38
package.json
38
package.json
|
@ -23,50 +23,34 @@
|
||||||
"@babel/plugin-transform-async-to-generator": "^7.1.0",
|
"@babel/plugin-transform-async-to-generator": "^7.1.0",
|
||||||
"@babel/preset-env": "^7.1.0",
|
"@babel/preset-env": "^7.1.0",
|
||||||
"babel-core": "^7.0.0-bridge.0",
|
"babel-core": "^7.0.0-bridge.0",
|
||||||
|
"chai": "^4.2.0",
|
||||||
|
"chai-as-promised": "^7.1.1",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-babel": "^8.0.0-beta.2",
|
"gulp-babel": "^8.0.0-beta.2",
|
||||||
"gulp-clean": "^0.4.0",
|
"gulp-clean": "^0.4.0",
|
||||||
"gulp-nodemon": "^2.2.1",
|
"gulp-nodemon": "^2.2.1",
|
||||||
"gulp-print": "^5.0.0",
|
"gulp-print": "^5.0.0",
|
||||||
"jest": "^23.6.0",
|
"mocha": "^5.2.0",
|
||||||
"nodemon": "^1.18.4",
|
"nodemon": "^1.18.4",
|
||||||
"sinon": "^7.1.1",
|
"sinon": "^7.1.1",
|
||||||
"supertest": "^3.3.0"
|
"supertest": "^3.3.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server.js",
|
"start": "node server.js",
|
||||||
"test": "jest",
|
"test": "mocha --require @babel/register",
|
||||||
"testw": "jest --watchAll",
|
"testw": "mocha --require @babel/register --watch",
|
||||||
"devel": "gulp devel",
|
"devel": "gulp devel",
|
||||||
"clean": "gulp clean",
|
"clean": "gulp clean",
|
||||||
"build": "gulp build",
|
"build": "gulp build",
|
||||||
"image": "docker build -t statusteam/ghcmgr .",
|
"image": "docker build -t statusteam/ghcmgr .",
|
||||||
"push": "docker push statusteam/ghcmgr"
|
"push": "docker push statusteam/ghcmgr"
|
||||||
},
|
},
|
||||||
"jest": {
|
"keywords": [
|
||||||
"moduleFileExtensions": [
|
"github",
|
||||||
"js",
|
"comments",
|
||||||
"json"
|
"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": "",
|
"author": "",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Builds {
|
||||||
async getBuilds (pr) {
|
async getBuilds (pr) {
|
||||||
const builds = await this.builds.chain()
|
const builds = await this.builds.chain()
|
||||||
.find({pr})
|
.find({pr})
|
||||||
.compoundsort(['$loki', 'platform', 'id'])
|
.compoundsort(['$loki', 'id'])
|
||||||
.data()
|
.data()
|
||||||
/* strip the $loki attribute */
|
/* strip the $loki attribute */
|
||||||
return builds.map((b) => {
|
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