Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40b618f

Browse files
committed
🎨 test
1 parent 4b985a4 commit 40b618f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/controllers/file-patch-controller.test.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,26 +191,24 @@ describe('FilePatchController', () => {
191191
const hunkViewsByHunk = new Map();
192192
function registerHunkView(hunk, view) { hunkViewsByHunk.set(hunk, view); }
193193

194-
// enqueue two stage operations before the first has a chance to be applied
195194
const controller = new FilePatchController({filePatch: unstagedFilePatch, repository, stagingStatus: 'unstaged', registerHunkView});
196195
const view = controller.refs.filePatchView;
197196
let hunk = unstagedFilePatch.getHunks()[0];
198197
let lines = hunk.getLines();
199198
let hunkView = hunkViewsByHunk.get(hunk);
200199
hunkView.props.mousedownOnLine({detail: 1}, hunk, lines[1]);
201200
view.mouseup();
202-
const firstOpPromises = hunkView.props.didClickStageButton();
203201

202+
// stage lines in rapid succession
203+
// second stage action is a no-op since the first staging operation is in flight
204+
const line1StagingPromises = hunkView.props.didClickStageButton();
204205
await hunkView.props.didClickStageButton();
205206

206-
await firstOpPromises.stageOperationPromise;
207-
208-
// refresh the hunks
209-
await repository.refresh();
207+
await line1StagingPromises.stageOperationPromise;
208+
await repository.refresh(); // clear the cached file patches
210209
const modifiedFilePatch = await repository.getFilePatchForPath('sample.js');
211210
await controller.update({filePatch: modifiedFilePatch, repository, stagingStatus: 'unstaged', registerHunkView});
212-
213-
await firstOpPromises.selectionUpdatePromise;
211+
await line1StagingPromises.selectionUpdatePromise;
214212

215213
// assert that only line 1 has been staged
216214
let expectedLines = originalLines.slice();
@@ -226,9 +224,8 @@ describe('FilePatchController', () => {
226224
hunkView.props.mousedownOnLine({detail: 1}, hunk, lines[2]);
227225
view.mouseup();
228226

229-
const thirdOpPromises = hunkView.props.didClickStageButton();
230-
231-
await thirdOpPromises.stageOperationPromise;
227+
const line2StagingPromises = hunkView.props.didClickStageButton();
228+
await line2StagingPromises.stageOperationPromise;
232229

233230
// assert that line 2 has now been staged
234231
expectedLines = originalLines.slice();

0 commit comments

Comments
 (0)