1
1
import { escape } from 'node:querystring' ;
2
- import { beforeEach , afterEach , serial } from 'ava' ;
2
+
3
+ import nock from 'nock' ;
3
4
import { repeat } from 'lodash-es' ;
4
- import { cleanAll } from 'nock ' ;
5
- import { stub } from 'sinon ' ;
6
- import proxyquire from 'proxyquire ' ;
5
+ import sinon from 'sinon ' ;
6
+ import test from 'ava ' ;
7
+ import quibble from 'quibble ' ;
7
8
8
9
import { ISSUE_ID } from '../lib/definitions/constants.js' ;
9
10
import getReleaseLinks from '../lib/get-release-links.js' ;
10
11
import { authenticate } from './helpers/mock-github.js' ;
11
- import rateLimit from './helpers/rate-limit.js' ;
12
+ import * as RATE_LIMIT_MOCK from './helpers/rate-limit.js' ;
12
13
13
14
/* eslint camelcase: ["error", {properties: "never"}] */
14
15
15
- const success = proxyquire ( '../ lib/success' , {
16
- './get-client' : proxyquire ( '../lib/get-client' , { './ definitions/rate-limit' : rateLimit } ) ,
17
- } ) ;
16
+ // mock rate limit imported via lib/get-client.js
17
+ await quibble . esm ( '../lib/definitions/rate-limit.js' , RATE_LIMIT_MOCK )
18
+ const success = ( await import ( '../lib/success.js' ) ) . default
18
19
19
20
test . beforeEach ( ( t ) => {
20
21
// Mock logger
21
- t . context . log = stub ( ) ;
22
- t . context . error = stub ( ) ;
22
+ t . context . log = sinon . stub ( ) ;
23
+ t . context . error = sinon . stub ( ) ;
23
24
t . context . logger = { log : t . context . log , error : t . context . error } ;
24
25
} ) ;
25
26
26
27
test . afterEach . always ( ( ) => {
27
28
// Clear nock
28
- cleanAll ( ) ;
29
+ nock . cleanAll ( ) ;
29
30
} ) ;
30
31
31
32
test . serial (
@@ -701,6 +702,7 @@ test.serial('Editing the release to include all release links at the top', async
701
702
{ name : 'S3' , url : 's3://my-bucket/release-asset' } ,
702
703
{ name : 'Docker: docker.io/python:slim' } ,
703
704
] ;
705
+
704
706
const github = authenticate ( env )
705
707
. get ( `/repos/${ owner } /${ repo } ` )
706
708
. reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
@@ -721,7 +723,7 @@ test.serial('Editing the release to include all release links at the top', async
721
723
)
722
724
. reply ( 200 , { items : [ ] } )
723
725
. patch ( `/repos/${ owner } /${ repo } /releases/${ releaseId } ` , {
724
- body : [ ... getReleaseLinks ( releases ) , '\n---\n' , nextRelease . notes ] ,
726
+ body : getReleaseLinks ( releases ) + '\n---\n' + nextRelease . notes ,
725
727
} )
726
728
. reply ( 200 , { html_url : releaseUrl } ) ;
727
729
@@ -985,7 +987,7 @@ test.serial('Ignore errors when adding comments and closing issues', async (t) =
985
987
. patch ( `/repos/${ owner } /${ repo } /issues/3` , { state : 'closed' } )
986
988
. reply ( 200 , { html_url : 'https://github.com/issues/3' } ) ;
987
989
988
- const [ error1 , error2 ] = await t . throwsAsync (
990
+ const { errors : [ error1 , error2 ] } = await t . throwsAsync (
989
991
success ( pluginConfig , {
990
992
env,
991
993
options,
0 commit comments