11import { describe , expect , jest , test } from '@jest/globals' ;
2+ import * as fs from 'fs' ;
3+ import * as path from 'path' ;
4+
25import { Inputs } from '../src/context' ;
36import { Label , Labeler , LabelStatus } from '../src/labeler' ;
47
5- import repoLabels from './fixtures/repoLabels.json' ;
8+ const fixturesDir = path . join ( __dirname , 'fixtures' ) ;
9+
610// eslint-disable-next-line @typescript-eslint/no-explicit-any
711jest . 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' ) ) ;
913} ) ;
1014
1115const cases = [
1216 [
1317 'labels.update.yml' ,
1418 {
1519 githubToken : 'n/a' ,
16- yamlFile : './__tests__/fixtures/ labels.update.yml',
20+ yamlFile : path . join ( fixturesDir , ' labels.update.yml') ,
1721 skipDelete : true ,
1822 dryRun : true ,
1923 exclude : [ ]
@@ -32,7 +36,7 @@ const cases = [
3236 'labels.exclude1.yml' ,
3337 {
3438 githubToken : 'n/a' ,
35- yamlFile : './__tests__/fixtures/ labels.exclude1.yml',
39+ yamlFile : path . join ( fixturesDir , ' labels.exclude1.yml') ,
3640 skipDelete : true ,
3741 dryRun : true ,
3842 exclude : [ '* d*' , '*enhancement' , '*fix' ]
@@ -51,7 +55,7 @@ const cases = [
5155 'labels.exclude2.yml' ,
5256 {
5357 githubToken : 'n/a' ,
54- yamlFile : './__tests__/fixtures/ labels.exclude2.yml',
58+ yamlFile : path . join ( fixturesDir , ' labels.exclude2.yml') ,
5559 skipDelete : true ,
5660 dryRun : true ,
5761 exclude : [ '*fix' ]
@@ -70,7 +74,7 @@ const cases = [
7074 'labels.hexcodes.yml' ,
7175 {
7276 githubToken : 'n/a' ,
73- yamlFile : './__tests__/fixtures/ labels.hexcodes.yml',
77+ yamlFile : path . join ( fixturesDir , ' labels.hexcodes.yml') ,
7478 skipDelete : true ,
7579 dryRun : true ,
7680 exclude : [ ]
@@ -106,7 +110,8 @@ describe('run', () => {
106110 delete : 0 ,
107111 error : 0
108112 } ;
109- for ( const label of await labeler . labels ) {
113+ const labels = await labeler . labels ;
114+ for ( const label of labels ) {
110115 switch ( label . ghaction_status ) {
111116 case LabelStatus . Exclude : {
112117 res . exclude ++ ;
0 commit comments