Add test case

This commit is contained in:
anthonylaye
2022-06-16 17:50:53 +02:00
parent fcb780e2b5
commit 965058f5bb
2 changed files with 23 additions and 1 deletions

View File

@@ -223,6 +223,28 @@ describe('addToProject', () => {
expect(gqlMock).not.toHaveBeenCalled()
})
test('does not add matching issues with labels filter with NOT label-operator', async () => {
mockGetInput({
'project-url': 'https://github.com/orgs/github/projects/1',
'github-token': 'gh_token',
labeled: 'bug, new',
'label-operator': 'NOT'
})
github.context.payload = {
issue: {
number: 1,
labels: [{name: 'bug'}]
}
}
const infoSpy = jest.spyOn(core, 'info')
const gqlMock = mockGraphQL()
await addToProject()
expect(infoSpy).toHaveBeenCalledWith(`Skipping issue 1 because it contains one of the labels: bug, new`)
expect(gqlMock).not.toHaveBeenCalled()
})
test('adds matching issues with multiple label filters', async () => {
mockGetInput({
'project-url': 'https://github.com/orgs/github/projects/1',

View File

@@ -15,7 +15,7 @@ inputs:
description: A comma-separated list of labels to use as a filter for issue to be added
label-operator:
required: false
description: The behavior of the labels filter, AND to match all labels, OR to match any label (default is OR)
description: The behavior of the labels filter, AND to match all labels, OR to match any label, NOT to exclude any listed label (default is OR)
runs:
using: 'node16'
main: 'dist/index.js'