Add tests for selectors hasEditorUndo & hasEditorRedo

[MAILPOET-3085]
This commit is contained in:
Jan Lysý
2020-11-18 17:56:43 +01:00
committed by Veljko V
parent 01a386b6ff
commit 75d451b9d1

View File

@ -59,4 +59,68 @@ describe('Selectors', () => {
expect(result).to.equal('Hello 2');
});
});
describe('hasEditorUndo', () => {
it('Should return false for empty history', () => {
const state = {
editorHistory: [],
editorHistoryOffset: 0,
};
expect(selectors.hasEditorUndo(state)).to.equal(false);
});
it('Should return true for one record in history', () => {
const state = {
editorHistory: [
{ data: 'some data' },
],
editorHistoryOffset: 0,
};
expect(selectors.hasEditorUndo(state)).to.equal(true);
});
it('Should return false for two records in history on offset one', () => {
const state = {
editorHistory: [
{ data: 'some data 1' },
{ data: 'some data 2' },
],
editorHistoryOffset: 1,
};
expect(selectors.hasEditorUndo(state)).to.equal(false);
});
it('Should return true for three records in history on offset one', () => {
const state = {
editorHistory: [
{ data: 'some data 1' },
{ data: 'some data 2' },
{ data: 'some data 3' },
],
editorHistoryOffset: 1,
};
expect(selectors.hasEditorUndo(state)).to.equal(true);
});
});
describe('hasEditorRedo', () => {
it('Should return false for empty history', () => {
const state = {
editorHistory: [],
editorHistoryOffset: 0,
};
expect(selectors.hasEditorRedo(state)).to.equal(false);
});
it('Should return true for two records in history on offset one', () => {
const state = {
editorHistory: [
{ data: 'some data 1' },
{ data: 'some data 2' },
],
editorHistoryOffset: 1,
};
expect(selectors.hasEditorRedo(state)).to.equal(true);
});
});
});