From caeaa479c8f284480f1d978a7428858820ded189 Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Wed, 14 Nov 2018 11:29:16 -0500 Subject: [PATCH] Update staging operation tests for the new patch comparison logic --- test/controllers/file-patch-controller.test.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/controllers/file-patch-controller.test.js b/test/controllers/file-patch-controller.test.js index f7f6abb1db..2ea7d2d90e 100644 --- a/test/controllers/file-patch-controller.test.js +++ b/test/controllers/file-patch-controller.test.js @@ -4,6 +4,7 @@ import React from 'react'; import {shallow} from 'enzyme'; import FilePatchController from '../../lib/controllers/file-patch-controller'; +import FilePatch from '../../lib/models/patch/file-patch'; import * as reporterProxy from '../../lib/reporter-proxy'; import {cloneRepository, buildRepository} from '../helpers'; @@ -151,14 +152,22 @@ describe('FilePatchController', function() { const wrapper = shallow(buildApp({relPath: 'a.txt', stagingStatus: 'unstaged'})); assert.strictEqual(await wrapper.find('FilePatchView').prop('toggleFile')(), 'staged'); - wrapper.setProps({stagingStatus: 'staged'}); + // No-op assert.isNull(await wrapper.find('FilePatchView').prop('toggleFile')()); - const promise = wrapper.instance().patchChangePromise; + // Simulate an identical patch arriving too soon wrapper.setProps({filePatch: filePatch.clone()}); + + // Still a no-op + assert.isNull(await wrapper.find('FilePatchView').prop('toggleFile')()); + + // Simulate updated patch arrival + const promise = wrapper.instance().patchChangePromise; + wrapper.setProps({filePatch: FilePatch.createNull()}); await promise; - assert.strictEqual(await wrapper.find('FilePatchView').prop('toggleFile')(), 'unstaged'); + // Performs an operation again + assert.strictEqual(await wrapper.find('FilePatchView').prop('toggleFile')(), 'staged'); }); });