Skip to content

Commit beeb0b1

Browse files
authored
chore: bump up for @actions/github to v5.0.0 (kentaro-m#63)
* test: fix tests to adapt @actions/github v5.0.0 * chore: bump up for @actions/github to v5.0.0 * test: use toThrowError matcher in tests which functions throw error
1 parent 216069a commit beeb0b1

9 files changed

+1064
-1592
lines changed

__tests__/handler.test.ts

+384-315
Large diffs are not rendered by default.

__tests__/utils.test.ts

+26-18
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,20 @@ describe('chooseUsersFromGroups', () => {
188188

189189
describe('fetchConfigurationFile', () => {
190190
test('fetchs the configuration file', async () => {
191-
const client = new github.GitHub('token')
192-
193-
client.repos = {
194-
getContents: jest.fn().mockImplementation(async () => ({
195-
data: {
196-
content:
197-
'IyBTZXQgdG8gdHJ1ZSB0byBhZGQgcmV2aWV3ZXJzIHRvIHB1bGwgcmVxdWVzdHMNCmFkZFJldmlld2VyczogdHJ1ZQ0KDQojIFNldCB0byB0cnVlIHRvIGFkZCBhc3NpZ25lZXMgdG8gcHVsbCByZXF1ZXN0cw0KYWRkQXNzaWduZWVzOiBmYWxzZQ0KDQojIEEgbGlzdCBvZiByZXZpZXdlcnMgdG8gYmUgYWRkZWQgdG8gcHVsbCByZXF1ZXN0cyAoR2l0SHViIHVzZXIgbmFtZSkNCnJldmlld2VyczoNCiAgLSByZXZpZXdlckENCiAgLSByZXZpZXdlckINCiAgLSByZXZpZXdlckM=',
191+
;(github.getOctokit as jest.Mock).mockImplementation(() => ({
192+
rest: {
193+
repos: {
194+
getContent: async () => ({
195+
data: {
196+
content:
197+
'IyBTZXQgdG8gdHJ1ZSB0byBhZGQgcmV2aWV3ZXJzIHRvIHB1bGwgcmVxdWVzdHMNCmFkZFJldmlld2VyczogdHJ1ZQ0KDQojIFNldCB0byB0cnVlIHRvIGFkZCBhc3NpZ25lZXMgdG8gcHVsbCByZXF1ZXN0cw0KYWRkQXNzaWduZWVzOiBmYWxzZQ0KDQojIEEgbGlzdCBvZiByZXZpZXdlcnMgdG8gYmUgYWRkZWQgdG8gcHVsbCByZXF1ZXN0cyAoR2l0SHViIHVzZXIgbmFtZSkNCnJldmlld2VyczoNCiAgLSByZXZpZXdlckENCiAgLSByZXZpZXdlckINCiAgLSByZXZpZXdlckM=',
198+
},
199+
}),
198200
},
199-
})),
200-
} as any
201+
},
202+
}))
203+
204+
const client = github.getOctokit('token')
201205

202206
const config = await fetchConfigurationFile(client, {
203207
owner: 'kentaro-m',
@@ -214,17 +218,21 @@ describe('fetchConfigurationFile', () => {
214218
})
215219

216220
test('responds with an error if failure to fetch the configuration file', async () => {
217-
const client = new github.GitHub('token')
218-
219-
client.repos = {
220-
getContents: jest.fn().mockImplementation(async () => ({
221-
data: {
222-
content: '',
221+
;(github.getOctokit as jest.Mock).mockImplementation(() => ({
222+
rest: {
223+
repos: {
224+
getContent: async () => ({
225+
data: {
226+
content: '',
227+
},
228+
}),
223229
},
224-
})),
225-
} as any
230+
},
231+
}))
232+
233+
const client = github.getOctokit('token')
226234

227-
expect(
235+
expect(async () =>
228236
fetchConfigurationFile(client, {
229237
owner: 'kentaro-m',
230238
repo: 'auto-assign-action-test',

0 commit comments

Comments
 (0)