mirror of
https://github.com/actions/labeler.git
synced 2025-12-11 03:58:05 +00:00
33 lines
979 B
TypeScript
33 lines
979 B
TypeScript
import {checkGlobs, MatchConfig} from '../src/labeler';
|
|
|
|
import * as core from '@actions/core';
|
|
|
|
jest.mock('@actions/core');
|
|
|
|
beforeAll(() => {
|
|
jest.spyOn(core, 'getInput').mockImplementation((name, options) => {
|
|
return jest.requireActual('@actions/core').getInput(name, options);
|
|
});
|
|
});
|
|
|
|
// I have to double cast here as this is what comes from js-yaml looks like which then gets transformed in toMatchConfig
|
|
const matchConfig = [
|
|
{'changed-files': [{any: ['*.txt']}]}
|
|
] as unknown as MatchConfig[];
|
|
|
|
describe('checkGlobs', () => {
|
|
it('returns true when our pattern does match changed files', () => {
|
|
const changedFiles = ['foo.txt', 'bar.txt'];
|
|
const result = checkGlobs(changedFiles, matchConfig);
|
|
|
|
expect(result).toBeTruthy();
|
|
});
|
|
|
|
it('returns false when our pattern does not match changed files', () => {
|
|
const changedFiles = ['foo.docx'];
|
|
const result = checkGlobs(changedFiles, matchConfig);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
});
|