mirror of
https://github.com/actions/labeler.git
synced 2025-12-13 13:07:24 +00:00
Add more unit tests for changedFiles.ts
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import * as github from '@actions/github';
|
|
||||||
import {
|
import {
|
||||||
ChangedFilesMatchConfig,
|
ChangedFilesMatchConfig,
|
||||||
checkAll,
|
checkAll,
|
||||||
@@ -9,23 +8,47 @@ import {
|
|||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
jest.mock('@actions/github');
|
jest.mock('@actions/github');
|
||||||
|
|
||||||
describe(checkAll, () => {
|
describe('checkAll', () => {
|
||||||
describe('when all the patterns match', () => {
|
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||||
it.todo('returns true');
|
|
||||||
|
describe('when the globs match every file that has changed', () => {
|
||||||
|
const globs = ['*.txt'];
|
||||||
|
|
||||||
|
it('returns true', () => {
|
||||||
|
const result = checkAll(changedFiles, globs);
|
||||||
|
expect(result).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when no the patterns match', () => {
|
describe(`when the globs don't match every file that has changed`, () => {
|
||||||
it.todo('returns false');
|
const globs = ['foo.txt'];
|
||||||
|
|
||||||
|
it('returns false', () => {
|
||||||
|
const result = checkAll(changedFiles, globs);
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe(checkAny, () => {
|
describe('checkAny', () => {
|
||||||
describe('when any provided patterns matches one of the files changed', () => {
|
const changedFiles = ['foo.txt', 'bar.txt'];
|
||||||
it.todo('returns true');
|
|
||||||
|
describe('when the globs match any of the files that have changed', () => {
|
||||||
|
const globs = ['foo.txt'];
|
||||||
|
|
||||||
|
it('returns true', () => {
|
||||||
|
const result = checkAny(changedFiles, globs);
|
||||||
|
expect(result).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when no the patterns match', () => {
|
describe('when none of the globs match any files that have changed', () => {
|
||||||
it.todo('returns false');
|
const globs = ['*.md'];
|
||||||
|
|
||||||
|
it('returns false', () => {
|
||||||
|
const result = checkAny(changedFiles, globs);
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -125,6 +148,7 @@ describe('toChangedFilesMatchConfig', () => {
|
|||||||
|
|
||||||
describe('and the value is an array of strings', () => {
|
describe('and the value is an array of strings', () => {
|
||||||
const config = {'changed-files': ['testing']};
|
const config = {'changed-files': ['testing']};
|
||||||
|
|
||||||
it(`sets the array under an 'any' key`, () => {
|
it(`sets the array under an 'any' key`, () => {
|
||||||
const result = toChangedFilesMatchConfig(config);
|
const result = toChangedFilesMatchConfig(config);
|
||||||
expect(result).toMatchObject<ChangedFilesMatchConfig>({
|
expect(result).toMatchObject<ChangedFilesMatchConfig>({
|
||||||
|
|||||||
Reference in New Issue
Block a user