Add tests for selectors hasEditorUndo & hasEditorRedo
[MAILPOET-3085]
This commit is contained in:
@@ -59,4 +59,68 @@ describe('Selectors', () => {
|
|||||||
expect(result).to.equal('Hello 2');
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user