@@ -2,32 +2,33 @@ import {stat} from 'node:fs/promises';
2
2
import { resolve } from 'node:path' ;
3
3
import { escape } from 'node:querystring' ;
4
4
5
+ import nock from 'nock' ;
6
+ import quibble from "quibble"
7
+ import sinon from 'sinon' ;
8
+ import tempy from 'tempy' ;
5
9
import test from 'ava' ;
6
- import { cleanAll } from 'nock' ;
7
- import { stub } from 'sinon' ;
8
- import proxyquire from 'proxyquire' ;
9
- import { directory } from 'tempy' ;
10
10
11
11
import { authenticate , upload } from './helpers/mock-github.js' ;
12
- import rateLimit from './helpers/rate-limit.js' ;
12
+ import * as RATE_LIMIT_MOCK from './helpers/rate-limit.js' ;
13
13
14
14
/* eslint camelcase: ["error", {properties: "never"}] */
15
15
16
+ // mock rate limit imported via lib/get-client.js
17
+ await quibble . esm ( '../lib/definitions/rate-limit.js' , RATE_LIMIT_MOCK ) // eslint-disable-line
18
+ const publish = ( await import ( '../lib/publish.js' ) ) . default
19
+
16
20
const cwd = 'test/fixtures/files' ;
17
- const publish = proxyquire ( '../lib/publish' , {
18
- './get-client' : proxyquire ( '../lib/get-client' , { './definitions/rate-limit' : rateLimit } ) ,
19
- } ) ;
20
21
21
22
test . beforeEach ( ( t ) => {
22
23
// Mock logger
23
- t . context . log = stub ( ) ;
24
- t . context . error = stub ( ) ;
24
+ t . context . log = sinon . stub ( ) ;
25
+ t . context . error = sinon . stub ( ) ;
25
26
t . context . logger = { log : t . context . log , error : t . context . error } ;
26
27
} ) ;
27
28
28
29
test . afterEach . always ( ( ) => {
29
30
// Clear nock
30
- cleanAll ( ) ;
31
+ nock . cleanAll ( ) ;
31
32
} ) ;
32
33
33
34
test . serial ( 'Publish a release' , async ( t ) => {
@@ -334,7 +335,7 @@ test.serial('Publish a release with an array of missing assets', async (t) => {
334
335
const owner = 'test_user' ;
335
336
const repo = 'test_repo' ;
336
337
const env = { GITHUB_TOKEN : 'github_token' } ;
337
- const emptyDirectory = directory ( ) ;
338
+ const emptyDirectory = tempy . directory ( ) ;
338
339
const pluginConfig = { assets : [ emptyDirectory , { path : 'missing.txt' , name : 'missing.txt' } ] } ;
339
340
const nextRelease = { gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
340
341
const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
0 commit comments