History Tests

This commit is contained in:
Sidharth Vinod
2021-05-24 01:59:22 +05:30
parent d3a2906c1c
commit 5190ea0201
+37 -37
View File
@@ -3,44 +3,44 @@ describe('Save History', () => {
cy.clearLocalStorage();
cy.visit('/edit');
});
// it('should save when clicked', () => {
// cy.get('#historyList').find('li').should('have.length', 0);
// cy.get('#historyList').contains('No items in History');
// cy.get('#saveHistory').click();
// cy.get('#historyList').find('No items in History').should('not.exist');
// cy.get('#historyList').find('li').should('have.length', 1);
// cy.get('#saveHistory').click();
// cy.on('window:alert', (str) => {
// expect(str).to.equal('State already saved.');
// });
// cy.on('window:confirm', () => true);
// cy.get('#editor').type(' C --> HistoryTest');
// cy.get('#saveHistory').click();
// cy.get('#historyList').find('li').should('have.length', 2);
// });
it('should save when clicked', () => {
cy.get('#historyList').find('li').should('have.length', 0);
cy.get('#historyList').contains('No items in History');
cy.get('#saveHistory').click();
cy.get('#historyList').find('No items in History').should('not.exist');
cy.get('#historyList').find('li').should('have.length', 1);
cy.get('#saveHistory').click();
cy.on('window:alert', (str) => {
expect(str).to.equal('State already saved.');
});
cy.on('window:confirm', () => true);
cy.get('#editor').type(' C --> HistoryTest');
cy.get('#saveHistory').click();
cy.get('#historyList').find('li').should('have.length', 2);
});
// it('should be able to restore and delete', () => {
// cy.get('#saveHistory').click();
// cy.get('#editor').type(' C --> HistoryTest');
// cy.get('#historyList').find('No items in History').should('not.exist');
// cy.get('#historyList').find('li').should('have.length', 1);
// cy.contains('HistoryTest');
// cy.contains('Restore').click();
// cy.contains('HistoryTest').should('not.exist');
// cy.contains('Delete').click();
// cy.get('#historyList').find('li').should('have.length', 0);
// cy.get('#historyList').contains('No items in History');
// cy.get('#saveHistory').click();
// cy.get('#editor').type(' C --> HistoryTest');
// cy.get('#saveHistory').click();
// cy.get('#editor').type('ing');
// cy.get('#clearHistory').click();
// cy.on('window:alert', (str) => {
// expect(str).to.equal('Clear all saved items?');
// });
// cy.on('window:confirm', () => true);
// cy.get('#historyList').contains('No items in History');
// });
it('should be able to restore and delete', () => {
cy.get('#saveHistory').click();
cy.get('#editor').type(' C --> HistoryTest');
cy.get('#historyList').find('No items in History').should('not.exist');
cy.get('#historyList').find('li').should('have.length', 1);
cy.contains('HistoryTest');
cy.contains('Restore').click();
cy.contains('HistoryTest').should('not.exist');
cy.contains('Delete').click();
cy.get('#historyList').find('li').should('have.length', 0);
cy.get('#historyList').contains('No items in History');
cy.get('#saveHistory').click();
cy.get('#editor').type(' C --> HistoryTest');
cy.get('#saveHistory').click();
cy.get('#editor').type('ing');
cy.get('#clearHistory').click();
cy.on('window:alert', (str) => {
expect(str).to.equal('Clear all saved items?');
});
cy.on('window:confirm', () => true);
cy.get('#historyList').contains('No items in History');
});
it('should auto save history', () => {
cy.clock();