Skip to content

Commit

Permalink
Merge pull request #1 from iansan5653/fix-url-match
Browse files Browse the repository at this point in the history
Resolve conflicts & invert test assertion
  • Loading branch information
saravanan30erd authored Mar 31, 2023
2 parents 38a0adc + 74235d0 commit 039f00e
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 213 deletions.
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/github.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 28 additions & 14 deletions __tests__/add-to-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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/<orgs-or-users>/<ownerName>/projects/<projectNumber>',
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 () => {
Expand Down
11 changes: 6 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 039f00e

Please sign in to comment.