1
1
import { describe , expect , jest , test } from '@jest/globals' ;
2
+ import * as fs from 'fs' ;
3
+ import * as path from 'path' ;
4
+
2
5
import { Inputs } from '../src/context' ;
3
6
import { Label , Labeler , LabelStatus } from '../src/labeler' ;
4
7
5
- import repoLabels from './fixtures/repoLabels.json' ;
8
+ const fixturesDir = path . join ( __dirname , 'fixtures' ) ;
9
+
6
10
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7
11
jest . spyOn ( Labeler . prototype as any , 'getRepoLabels' ) . mockImplementation ( ( ) : Promise < Label [ ] > => {
8
- return < Promise < Label [ ] > > ( repoLabels as unknown ) ;
12
+ return < Promise < Label [ ] > > JSON . parse ( fs . readFileSync ( path . join ( fixturesDir , ' repoLabels.json' ) , 'utf-8' ) ) ;
9
13
} ) ;
10
14
11
15
const cases = [
12
16
[
13
17
'labels.update.yml' ,
14
18
{
15
19
githubToken : 'n/a' ,
16
- yamlFile : './__tests__/fixtures/ labels.update.yml',
20
+ yamlFile : path . join ( fixturesDir , ' labels.update.yml') ,
17
21
skipDelete : true ,
18
22
dryRun : true ,
19
23
exclude : [ ]
@@ -32,7 +36,7 @@ const cases = [
32
36
'labels.exclude1.yml' ,
33
37
{
34
38
githubToken : 'n/a' ,
35
- yamlFile : './__tests__/fixtures/ labels.exclude1.yml',
39
+ yamlFile : path . join ( fixturesDir , ' labels.exclude1.yml') ,
36
40
skipDelete : true ,
37
41
dryRun : true ,
38
42
exclude : [ '* d*' , '*enhancement' , '*fix' ]
@@ -51,7 +55,7 @@ const cases = [
51
55
'labels.exclude2.yml' ,
52
56
{
53
57
githubToken : 'n/a' ,
54
- yamlFile : './__tests__/fixtures/ labels.exclude2.yml',
58
+ yamlFile : path . join ( fixturesDir , ' labels.exclude2.yml') ,
55
59
skipDelete : true ,
56
60
dryRun : true ,
57
61
exclude : [ '*fix' ]
@@ -70,7 +74,7 @@ const cases = [
70
74
'labels.hexcodes.yml' ,
71
75
{
72
76
githubToken : 'n/a' ,
73
- yamlFile : './__tests__/fixtures/ labels.hexcodes.yml',
77
+ yamlFile : path . join ( fixturesDir , ' labels.hexcodes.yml') ,
74
78
skipDelete : true ,
75
79
dryRun : true ,
76
80
exclude : [ ]
@@ -106,7 +110,8 @@ describe('run', () => {
106
110
delete : 0 ,
107
111
error : 0
108
112
} ;
109
- for ( const label of await labeler . labels ) {
113
+ const labels = await labeler . labels ;
114
+ for ( const label of labels ) {
110
115
switch ( label . ghaction_status ) {
111
116
case LabelStatus . Exclude : {
112
117
res . exclude ++ ;
0 commit comments