Skip to content

Commit

Permalink
FIX When exiting compare mode, the version shown is the last selected…
Browse files Browse the repository at this point in the history
… version to compare from
  • Loading branch information
robbieaverill committed Aug 16, 2018
1 parent 9ca076d commit 81e9c0c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions client/src/state/historyviewer/HistoryViewerReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function historyViewerReducer(state = initialState, { type, paylo

return {
...state,
currentVersion: versionFrom,
compare: { versionFrom, versionTo },
};
}
Expand All @@ -99,6 +100,7 @@ export default function historyViewerReducer(state = initialState, { type, paylo

return {
...state,
currentVersion: versionFrom,
compare: { versionFrom, versionTo },
};
}
Expand Down
46 changes: 41 additions & 5 deletions client/src/state/historyviewer/tests/HistoryViewerReducer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,34 @@ describe('HistoryViewerReducer', () => {
expect(result.compare.versionFrom.Version).toBe(80);
expect(result.compare.versionTo).toBe(false);
});

it('sets the currentVersion to the compareFrom version', () => {
state = {
...state,
compare: {
versionFrom: {
Version: 50,
},
},
};

const result = historyViewerReducer(state, {
type: 'HISTORY_VIEWER.SET_COMPARE_FROM',
payload: {
version: { Version: 60 },
},
});

expect(result.currentVersion.Version).toBe(60);
});
});

describe('SET_COMPARE_TO', () => {
it('sets the compareTo version', () => {
const result = historyViewerReducer(state, {
type: 'HISTORY_VIEWER.SET_COMPARE_TO',
payload: {
version:
{
Version:
85
}
version: { Version: 85 }
},
});

Expand Down Expand Up @@ -213,4 +229,24 @@ describe('HistoryViewerReducer', () => {
expect(result.compare.versionTo.Version).toBe(50);
});
});

it('sets the currentVersion to the compareFrom version', () => {
state = {
...state,
compare: {
versionFrom: {
Version: 50,
},
},
};

const result = historyViewerReducer(state, {
type: 'HISTORY_VIEWER.SET_COMPARE_FROM',
payload: {
version: { Version: 60 },
},
});

expect(result.currentVersion.Version).toBe(60);
});
});

0 comments on commit 81e9c0c

Please sign in to comment.