Skip to content

Commit 596994e

Browse files
committed
test(*): fix tests
1 parent c9735b6 commit 596994e

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
"coverageDirectory": "<rootDir>/coverage",
5555
"coveragePathIgnorePatterns": [
5656
"index.ts",
57-
"AppConfig.ts"
57+
"AppConfig.ts",
58+
"server.ts"
5859
],
5960
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$",
6061
"moduleFileExtensions": [

src/App.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe("App", () => {
2828
payload: {
2929
pull_request: {}
3030
},
31-
issue: (payload: {body: string}): IPayload => ({
31+
issue: (payload: { body: string }): IPayload => ({
3232
number: 1,
3333
repo: "",
3434
owner: "",
@@ -58,7 +58,7 @@ describe("App", () => {
5858
payload: {
5959
issue: {}
6060
},
61-
issue: (payload: {body: string}): IPayload => ({
61+
issue: (payload: { body: string }): IPayload => ({
6262
number: 1,
6363
repo: "",
6464
owner: "",
@@ -90,7 +90,7 @@ describe("App", () => {
9090
payload: {
9191
issue: {}
9292
},
93-
issue: (payload: {body: string}): IPayload => ({
93+
issue: (payload: { body: string }): IPayload => ({
9494
number: 1,
9595
repo: "",
9696
owner: "",

src/App.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import * as Webhooks from "@octokit/webhooks";
2-
import {Application, Context, Probot} from "probot";
3-
import {getAppConfig} from "./AppConfig";
2+
import {Application, Context} from "probot";
43
import {GithubIssueHelper, IGithubIssueHelper} from "./GithubIssueHelper";
54
import {IPayloadHelper, PayloadHelper} from "./PayloadHelper";
65

76
export type TData = Webhooks.WebhookPayloadPullRequest | Webhooks.WebhookPayloadIssues;
87

9-
class App {
8+
export class App {
109
constructor(private ghHelper: IGithubIssueHelper, private payloadHelper: IPayloadHelper, private context: Context<TData>) {
1110
}
1211

@@ -38,13 +37,7 @@ This body won't be processed any further, please fix your template.
3837
this.context.log.debug(`updated ${PayloadHelper.isPr(this.context.payload) ? "PR" : "issue"} body`);
3938
} catch (e) {
4039
this.context.log.info(`Error: ${e.toString()}`);
41-
console.warn(`Error: ${e.toString()}`);
4240
await this.ghHelper.comment(this.context.issue({body: App.getErrorComment(e)}));
4341
}
4442
}
4543
}
46-
47-
const appConfig = getAppConfig();
48-
const probot = new Probot(appConfig);
49-
probot.load(App.handle);
50-
export {App, probot};

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import {probot} from "./App";
1+
import {Probot} from "probot";
2+
import {App} from "./App";
3+
import {getAppConfig} from "./AppConfig";
4+
const appConfig = getAppConfig();
5+
const probot = new Probot(appConfig);
6+
probot.load(App.handle);
27

38
// tslint:disable-next-line
49
export = probot.server;

src/server.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
import {probot} from "./App";
1+
import {Probot} from "probot";
2+
import {App} from "./App";
3+
import {getAppConfig} from "./AppConfig";
4+
5+
const appConfig = getAppConfig();
6+
const probot = new Probot(appConfig);
7+
probot.load(App.handle);
8+
29
probot.start();

0 commit comments

Comments
 (0)