Files
labeler/__tests__/labeler.test.ts
T

30 lines
864 B
TypeScript
Raw Normal View History

import {checkMatchConfigs, MatchConfig} from '../src/labeler';
2021-06-03 16:15:47 -04:00
import * as core from '@actions/core';
2021-06-03 16:15:47 -04:00
jest.mock('@actions/core');
2021-06-03 16:15:47 -04:00
beforeAll(() => {
jest.spyOn(core, 'getInput').mockImplementation((name, options) => {
return jest.requireActual('@actions/core').getInput(name, options);
2021-06-03 16:15:47 -04:00
});
});
const matchConfig: MatchConfig[] = [{changedFiles: {any: ['*.txt']}}];
2021-06-03 16:15:47 -04:00
describe('checkMatchConfigs', () => {
it('returns true when our pattern does match changed files', () => {
const changedFiles = ['foo.txt', 'bar.txt'];
const result = checkMatchConfigs(changedFiles, matchConfig);
2021-06-03 16:15:47 -04:00
expect(result).toBeTruthy();
});
it('returns false when our pattern does not match changed files', () => {
const changedFiles = ['foo.docx'];
const result = checkMatchConfigs(changedFiles, matchConfig);
2021-06-03 16:15:47 -04:00
expect(result).toBeFalsy();
});
});