Skip to content

Commit

Permalink
test: Add payload fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
jamacku committed Oct 19, 2022
1 parent 8d5f8aa commit 5c18021
Show file tree
Hide file tree
Showing 13 changed files with 2,651 additions and 516 deletions.
1,022 changes: 511 additions & 511 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

502 changes: 502 additions & 0 deletions dist/metadata.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/metadata.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/metadata.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"class-validator": "^0.13.2"
},
"devDependencies": {
"@octokit/webhooks": "^10.3.0",
"@octokit/webhooks-types": "^6.5.0",
"@types/jest": "28.1.7",
"@types/node": "18.0.4",
"@typescript-eslint/parser": "5.40.1",
Expand All @@ -43,6 +45,7 @@
"eslint-plugin-jest": "26.8.3",
"eslint-plugin-prettier": "4.2.1",
"js-yaml": "4.1.0",
"nock": "^13.2.9",
"prettier": "2.7.1",
"ts-node": "10.9.1",
"typescript": "4.8.4",
Expand Down
2 changes: 1 addition & 1 deletion src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class Metadata {
* Based on probot-metadata - https://github.com/probot/metadata
*/
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
class MetadataController {
export class MetadataController {
static readonly regex = /\n\n<!-- devel-freezer = (.*) -->/;

static async getMetadata(key: string, context: Context) {
Expand Down
38 changes: 38 additions & 0 deletions test/integration/fixtures/metadata.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
PullRequestOpenedEvent,
PullRequestReopenedEvent,
PullRequestSynchronizeEvent,
} from '@octokit/webhooks-types';

import { events } from '../../../src/events';

import payloadPullRequestOpened from '../fixtures/payloads/pull-request-opened.json';
import payloadPullRequestReopened from '../fixtures/payloads/pull-request-reopened.json';
import payloadPullRequestSynchronize from '../fixtures/payloads/pull-request-synchronize.json';

export interface IMetadataTestContext {
payloads: {
type: typeof events.pull_request[number];
payload:
| PullRequestOpenedEvent
| PullRequestReopenedEvent
| PullRequestSynchronizeEvent;
}[];
}

export const metadataContextFixture: IMetadataTestContext = {
payloads: [
{
type: 'pull_request.opened',
payload: payloadPullRequestOpened as PullRequestOpenedEvent,
},
{
type: 'pull_request.reopened',
payload: payloadPullRequestReopened as PullRequestReopenedEvent,
},
{
type: 'pull_request.synchronize',
payload: payloadPullRequestSynchronize as PullRequestSynchronizeEvent,
},
],
};
3 changes: 3 additions & 0 deletions test/integration/fixtures/payloads/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# About Payloads

> **Note**: Payloads were gathered from: [@octokit/webhooks](https://github.com/octokit/webhooks/tree/master/payload-examples)
Loading

0 comments on commit 5c18021

Please sign in to comment.