Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Update staging operation tests for the new patch comparison logic
Browse files Browse the repository at this point in the history
  • Loading branch information
smashwilson committed Nov 14, 2018
1 parent 2ce9ee1 commit caeaa47
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/controllers/file-patch-controller.test.js
Expand Up @@ -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';

Expand Down Expand Up @@ -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');
});
});

Expand Down

0 comments on commit caeaa47

Please sign in to comment.