1- import { Probot } from 'probot' ;
1+ import { Probot , ProbotOctokit } from 'probot' ;
22import nock from 'nock' ;
33import { afterEach , beforeEach , describe , expect , it } from 'vitest' ;
44
55import { addBasicPRLabels } from '../src/add-triage-labels' ;
66import { DOCUMENTATION_LABEL , SEMVER_LABELS , SEMVER_NONE_LABEL } from '../src/constants' ;
77import { loadFixture } from './utils' ;
88
9+ const GH_API = 'https://api.github.com' ;
10+
911const handler = async ( app : Probot ) => {
1012 addBasicPRLabels ( app ) ;
1113} ;
@@ -19,9 +21,10 @@ describe('add-triage-labels', () => {
1921
2022 robot = new Probot ( {
2123 githubToken : 'test' ,
22- secret : 'secret' ,
23- privateKey : 'private key' ,
24- appId : 690857 ,
24+ Octokit : ProbotOctokit . defaults ( {
25+ retry : { enabled : false } ,
26+ throttle : { enabled : false } ,
27+ } ) ,
2528 } ) ;
2629
2730 robot . load ( handler ) ;
@@ -35,13 +38,13 @@ describe('add-triage-labels', () => {
3538 it ( 'adds correct labels to documentation PRs' , async ( ) => {
3639 const payload = loadFixture ( 'add-triage-labels/docs_pr_opened.json' ) ;
3740
38- nock ( 'https://api.github.com' )
41+ nock ( GH_API )
3942 . get ( `/repos/electron/electron/issues/${ payload . number } /labels?per_page=100&page=1` )
4043 . reply ( 200 , [ ] ) ;
4144
42- nock ( 'https://api.github.com' )
43- . post ( `/repos/electron/electron/issues/${ payload . number } /labels` , ( body ) => {
44- expect ( body ) . toEqual ( [ SEMVER_LABELS . PATCH , DOCUMENTATION_LABEL ] ) ;
45+ nock ( GH_API )
46+ . post ( `/repos/electron/electron/issues/${ payload . number } /labels` , ( { labels } ) => {
47+ expect ( labels ) . toEqual ( [ SEMVER_LABELS . PATCH , DOCUMENTATION_LABEL ] ) ;
4548 return true ;
4649 } )
4750 . reply ( 200 ) ;
@@ -56,13 +59,13 @@ describe('add-triage-labels', () => {
5659 it ( 'adds correct labels to build PRs' , async ( ) => {
5760 const payload = loadFixture ( 'add-triage-labels/build_pr_opened.json' ) ;
5861
59- nock ( 'https://api.github.com' )
62+ nock ( GH_API )
6063 . get ( `/repos/electron/electron/issues/${ payload . number } /labels?per_page=100&page=1` )
6164 . reply ( 200 , [ ] ) ;
6265
63- nock ( 'https://api.github.com' )
64- . post ( `/repos/electron/electron/issues/${ payload . number } /labels` , ( body ) => {
65- expect ( body ) . toEqual ( [ SEMVER_NONE_LABEL ] ) ;
66+ nock ( GH_API )
67+ . post ( `/repos/electron/electron/issues/${ payload . number } /labels` , ( { labels } ) => {
68+ expect ( labels ) . toEqual ( [ SEMVER_NONE_LABEL ] ) ;
6669 return true ;
6770 } )
6871 . reply ( 200 ) ;
@@ -77,13 +80,13 @@ describe('add-triage-labels', () => {
7780 it ( 'adds correct labels to test PRs' , async ( ) => {
7881 const payload = loadFixture ( 'add-triage-labels/test_pr_opened.json' ) ;
7982
80- nock ( 'https://api.github.com' )
83+ nock ( GH_API )
8184 . get ( `/repos/electron/electron/issues/${ payload . number } /labels?per_page=100&page=1` )
8285 . reply ( 200 , [ ] ) ;
8386
84- nock ( 'https://api.github.com' )
85- . post ( `/repos/electron/electron/issues/${ payload . number } /labels` , ( body ) => {
86- expect ( body ) . toEqual ( [ SEMVER_NONE_LABEL ] ) ;
87+ nock ( GH_API )
88+ . post ( `/repos/electron/electron/issues/${ payload . number } /labels` , ( { labels } ) => {
89+ expect ( labels ) . toEqual ( [ SEMVER_NONE_LABEL ] ) ;
8790 return true ;
8891 } )
8992 . reply ( 200 ) ;
@@ -98,13 +101,13 @@ describe('add-triage-labels', () => {
98101 it ( 'adds correct labels to CI PRs' , async ( ) => {
99102 const payload = loadFixture ( 'add-triage-labels/ci_pr_opened.json' ) ;
100103
101- nock ( 'https://api.github.com' )
104+ nock ( GH_API )
102105 . get ( `/repos/electron/electron/issues/${ payload . number } /labels?per_page=100&page=1` )
103106 . reply ( 200 , [ ] ) ;
104107
105- nock ( 'https://api.github.com' )
106- . post ( `/repos/electron/electron/issues/${ payload . number } /labels` , ( body ) => {
107- expect ( body ) . toEqual ( [ SEMVER_NONE_LABEL ] ) ;
108+ nock ( GH_API )
109+ . post ( `/repos/electron/electron/issues/${ payload . number } /labels` , ( { labels } ) => {
110+ expect ( labels ) . toEqual ( [ SEMVER_NONE_LABEL ] ) ;
108111 return true ;
109112 } )
110113 . reply ( 200 ) ;
0 commit comments