From 74235d0976f4cd605366efb765871e7f51999f93 Mon Sep 17 00:00:00 2001 From: Ian Sanders Date: Fri, 31 Mar 2023 19:43:22 +0000 Subject: [PATCH] Invert test that rejected non-jackfan.us.kg URLs --- __tests__/add-to-project.test.ts | 42 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/__tests__/add-to-project.test.ts b/__tests__/add-to-project.test.ts index f742589e..9c79f363 100644 --- a/__tests__/add-to-project.test.ts +++ b/__tests__/add-to-project.test.ts @@ -578,18 +578,13 @@ describe('addToProject', () => { expect(gqlMock).not.toHaveBeenCalled() }) - test(`throws an error when url isn't under the github.com domain`, async () => { - mockGetInput({ - 'project-url': 'https://notgithub.com/orgs/github/projects/1', - 'github-token': 'gh_token', - }) - + test(`works with URLs that are not under the github.com domain`, async () => { github.context.payload = { issue: { number: 1, - labels: [], + labels: [{name: 'bug'}], // eslint-disable-next-line camelcase - html_url: 'https://github.com/actions/add-to-project/issues/74', + html_url: 'https://notgithub.com/actions/add-to-project/issues/74', }, repository: { name: 'add-to-project', @@ -599,13 +594,32 @@ describe('addToProject', () => { }, } - const infoSpy = jest.spyOn(core, 'info') - const gqlMock = mockGraphQL() - await expect(addToProject()).rejects.toThrow( - 'https://notgithub.com/orgs/github/projects/1. Project URL should match the format https://github.com///projects/', + mockGraphQL( + { + test: /getProject/, + return: { + organization: { + projectV2: { + id: 'project-id', + }, + }, + }, + }, + { + test: /addProjectV2ItemById/, + return: { + addProjectV2ItemById: { + item: { + id: 'project-item-id', + }, + }, + }, + }, ) - expect(infoSpy).not.toHaveBeenCalled() - expect(gqlMock).not.toHaveBeenCalled() + + await addToProject() + + expect(outputs.itemId).toEqual('project-item-id') }) test('constructs the correct graphQL query given an organization owner', async () => {