-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from pullflow/release/1.2.2
🚂 Release 1.2.2
- Loading branch information
Showing
11 changed files
with
201 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
src/pullRequestQuickActions/pullRequestQuickActions.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import { describe, expect, it, jest } from '@jest/globals' | ||
import { window } from '../__mocks__/vscode' | ||
|
||
describe('Pull Request Quick Actions', () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks() | ||
mockAuthorization.Authorization.currentSession.mockReturnValue(mockSession) | ||
}) | ||
it('applies labels to pull request', async () => { | ||
const mockLabel = 'mock_label' | ||
window.showInputBox.mockReturnValue(mockLabel) | ||
await subject().applyLabel({ | ||
codeReview: mockModel, | ||
context: mockModel, | ||
statusBar: mockStatusBar, | ||
}) | ||
expect(mockPresence.Presence.set).toBeCalled() | ||
expect(mockPullRequestState.PullRequestState.updateWithDelay).toBeCalled() | ||
}) | ||
|
||
it('approves pull request', async () => { | ||
const mockText = 'mock_approve' | ||
window.showInputBox.mockReturnValue(mockText) | ||
await subject().approve({ | ||
codeReview: mockModel, | ||
context: mockModel, | ||
statusBar: mockStatusBar, | ||
}) | ||
expect( | ||
mockPullRequestQuickActionsApi.PullRequestQuickActionsApi.approve | ||
).toHaveBeenCalledWith({ | ||
body: mockText, | ||
codeReviewId: mockModel.id, | ||
authToken: mockSession.accessToken, | ||
context: mockModel, | ||
}) | ||
expect(mockPresence.Presence.set).toBeCalled() | ||
expect(mockPullRequestState.PullRequestState.updateWithDelay).toBeCalled() | ||
}) | ||
|
||
it('adds assignee to pull request', async () => { | ||
await subject().addAssignee({ | ||
codeReview: mockModel, | ||
context: mockModel, | ||
statusBar: mockStatusBar, | ||
}) | ||
expect(mockSpaceUserPicker.spaceUserPicker).toBeCalledWith( | ||
expect.objectContaining({ | ||
context: mockModel, | ||
placeholder: 'Select a user', | ||
title: 'Add assignee to pull request', | ||
}) | ||
) | ||
expect(mockPresence.Presence.set).toBeCalled() | ||
expect(mockPullRequestState.PullRequestState.updateWithDelay).toBeCalled() | ||
}) | ||
|
||
it('adds reviewer on pull request', async () => { | ||
await subject().requestReview({ | ||
codeReview: mockModel, | ||
context: mockModel, | ||
statusBar: mockStatusBar, | ||
}) | ||
expect(mockSpaceUserPicker.spaceUserPicker).toBeCalledWith( | ||
expect.objectContaining({ | ||
context: mockModel, | ||
placeholder: 'Select a user', | ||
title: 'Add reviewer to pull request', | ||
}) | ||
) | ||
expect(mockPresence.Presence.set).toBeCalled() | ||
expect(mockPullRequestState.PullRequestState.updateWithDelay).toBeCalled() | ||
}) | ||
}) | ||
|
||
export {} | ||
const subject = () => { | ||
jest.mock('../utils/authorization', () => mockAuthorization) | ||
jest.mock( | ||
'../api/pullRequestQuickActionsApi', | ||
() => mockPullRequestQuickActionsApi | ||
) | ||
jest.mock('../models/presence', () => mockPresence) | ||
jest.mock('../utils/pullRequestsState', () => mockPullRequestState) | ||
jest.mock('../views/quickpicks/spaceUserPicker', () => mockSpaceUserPicker) | ||
return require('./pullRequestQuickActions').PullRequestQuickActions | ||
} | ||
|
||
const mockAuthorization = { | ||
Authorization: { | ||
currentSession: jest.fn(), | ||
}, | ||
} | ||
const mockPullRequestQuickActionsApi = { | ||
PullRequestQuickActionsApi: { | ||
addLabels: jest.fn(), | ||
approve: jest.fn(), | ||
}, | ||
} | ||
const mockPresence = { | ||
Presence: { | ||
set: jest.fn(), | ||
}, | ||
} | ||
const mockPullRequestState = { | ||
PullRequestState: { | ||
update: jest.fn(), | ||
updateWithDelay: jest.fn(), | ||
}, | ||
} | ||
const mockSpaceUserPicker = { | ||
spaceUserPicker: jest.fn(), | ||
} | ||
const mockStatusBar = { | ||
text: 'mock_status_bar', | ||
} | ||
const mockModel = { | ||
id: '1', | ||
} | ||
const mockSession = { | ||
accessToken: 'mock_access_token', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.