From 5190ea020175c518149aa0ccd37cc217c0063074 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 24 May 2021 01:59:22 +0530 Subject: [PATCH] History Tests --- cypress/integration/history.spec.js | 74 ++++++++++++++--------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/cypress/integration/history.spec.js b/cypress/integration/history.spec.js index aa24d302..5bdedef0 100644 --- a/cypress/integration/history.spec.js +++ b/cypress/integration/history.spec.js @@ -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();