Skip to content

Commit 35e17ea

Browse files
Merge pull request #282 from technote-space/release/next-v2.0.11
release: v3.0.0
2 parents 67fc620 + 26370c8 commit 35e17ea

File tree

6 files changed

+171
-219
lines changed

6 files changed

+171
-219
lines changed

__tests__/api-helper1.test.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
/* eslint-disable no-magic-numbers */
22
import nock from 'nock';
33
import path from 'path';
4-
import {Octokit} from '@octokit/rest';
54
import {Utils} from '../src';
65
import {
76
disableNetConnect,
87
testEnv,
98
getContext,
109
getApiFixture,
11-
createResponse,
1210
spyOnStdout,
1311
stdoutCalledWith,
1412
} from '@technote-space/github-action-test-helper';
13+
import {GitCreateCommitResponseData} from '@octokit/types';
1514
import {ApiHelper, Logger} from '../src';
1615

1716
const rootDir = path.resolve(__dirname, 'fixtures');
@@ -33,7 +32,7 @@ const context = getContext({
3332
const octokit = Utils.getOctokit('test-token');
3433
const logger = new Logger();
3534

36-
const createCommitResponse = createResponse<Octokit.GitCreateCommitResponse>({
35+
const createCommitResponse: GitCreateCommitResponseData = {
3736
author: {
3837
date: '',
3938
email: '',
@@ -54,13 +53,13 @@ const createCommitResponse = createResponse<Octokit.GitCreateCommitResponse>({
5453
},
5554
url: '',
5655
verification: {
57-
payload: null,
56+
payload: '',
5857
reason: '',
59-
signature: null,
58+
signature: '',
6059
verified: true,
6160
},
62-
});
63-
const escape = value => encodeURIComponent(value).replace(new RegExp('%2F', 'g'), '%252F');
61+
};
62+
const escape = value => encodeURIComponent(value).replace(new RegExp('%2F', 'g'), '%252F');
6463

6564
describe('ApiHelper', () => {
6665
disableNetConnect(nock);
@@ -136,11 +135,9 @@ describe('ApiHelper', () => {
136135
expect(fn1).toBeCalledTimes(1);
137136
expect(fn2).toBeCalledTimes(1);
138137
expect(fn3).toBeCalledTimes(1);
139-
expect(tree).toHaveProperty('status');
138+
expect(tree).toHaveProperty('sha');
140139
expect(tree).toHaveProperty('url');
141-
expect(tree).toHaveProperty('headers');
142-
expect(tree).toHaveProperty('data');
143-
expect(tree.status).toBe(201);
140+
expect(tree).toHaveProperty('tree');
144141
});
145142
});
146143

@@ -161,19 +158,18 @@ describe('ApiHelper', () => {
161158
return getApiFixture(rootDir, 'repos.git.commits');
162159
});
163160

164-
const commit = await helper.createCommit('test commit message', createResponse<Octokit.GitCreateTreeResponse>({
161+
const commit = await helper.createCommit('test commit message', {
165162
sha: 'tree-sha',
166163
tree: [],
167164
url: '',
168-
}));
165+
});
169166

170167
expect(fn1).toBeCalledTimes(1);
171168
expect(fn2).toBeCalledTimes(1);
172-
expect(commit).toHaveProperty('status');
169+
expect(commit).toHaveProperty('sha');
170+
expect(commit).toHaveProperty('author');
173171
expect(commit).toHaveProperty('url');
174-
expect(commit).toHaveProperty('headers');
175-
expect(commit).toHaveProperty('data');
176-
expect(commit.status).toBe(201);
172+
expect(commit).toHaveProperty('tree');
177173
});
178174

179175
it('should create PR commit', async() => {
@@ -198,14 +194,17 @@ describe('ApiHelper', () => {
198194
},
199195
},
200196
}), logger);
201-
const commit = await helper.createCommit('test commit message', createResponse<Octokit.GitCreateTreeResponse>({
197+
const commit = await helper.createCommit('test commit message', {
202198
sha: 'tree-sha',
203199
tree: [],
204200
url: '',
205-
}));
201+
});
206202

207203
expect(fn).toBeCalledTimes(1);
208-
expect(commit.status).toBe(201);
204+
expect(commit).toHaveProperty('sha');
205+
expect(commit).toHaveProperty('author');
206+
expect(commit).toHaveProperty('url');
207+
expect(commit).toHaveProperty('tree');
209208
});
210209
});
211210

__tests__/api-helper2.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
/* eslint-disable no-magic-numbers */
22
import nock from 'nock';
33
import path from 'path';
4-
import {Octokit} from '@octokit/rest';
54
import {Utils} from '../src';
65
import {
76
disableNetConnect,
87
testEnv,
98
getContext,
109
getApiFixture,
11-
createResponse,
1210
spyOnStdout,
1311
stdoutCalledWith,
1412
} from '@technote-space/github-action-test-helper';
13+
import {GitCreateCommitResponseData} from '@octokit/types';
1514
import {ApiHelper, Logger} from '../src';
1615

1716
const rootDir = path.resolve(__dirname, 'fixtures');
@@ -36,7 +35,7 @@ const context = getContext({
3635
const octokit = Utils.getOctokit('test-token');
3736
const logger = new Logger();
3837

39-
const createCommitResponse = createResponse<Octokit.GitCreateCommitResponse>({
38+
const createCommitResponse: GitCreateCommitResponseData = {
4039
author: {
4140
date: '',
4241
email: '',
@@ -57,12 +56,12 @@ const createCommitResponse = createResponse<Octokit.GitCreateCommitResponse>({
5756
},
5857
url: '',
5958
verification: {
60-
payload: null,
59+
payload: '',
6160
reason: '',
62-
signature: null,
61+
signature: '',
6362
verified: true,
6463
},
65-
});
64+
};
6665

6766
describe('ApiHelper with params', () => {
6867
disableNetConnect(nock);

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@technote-space/github-action-helper",
3-
"version": "2.0.11",
3+
"version": "3.0.0",
44
"description": "Helper to filter GitHub Action.",
55
"author": {
66
"name": "Technote",
@@ -28,14 +28,15 @@
2828
"dependencies": {
2929
"@actions/core": "^1.2.4",
3030
"@actions/github": "^3.0.0",
31+
"@octokit/plugin-rest-endpoint-methods": "^4.0.0",
3132
"shell-escape": "^0.2.0",
3233
"sprintf-js": "^1.1.2"
3334
},
3435
"devDependencies": {
3536
"@commitlint/cli": "^9.0.1",
3637
"@commitlint/config-conventional": "^9.0.1",
37-
"@technote-space/github-action-test-helper": "^0.3.8",
38-
"@types/jest": "^26.0.2",
38+
"@technote-space/github-action-test-helper": "^0.4.0",
39+
"@types/jest": "^26.0.3",
3940
"@types/node": "^14.0.14",
4041
"@typescript-eslint/eslint-plugin": "^3.4.0",
4142
"@typescript-eslint/parser": "^3.4.0",

0 commit comments

Comments
 (0)