Last active
August 29, 2015 14:02
-
-
Save timlindvall/80e9d72df993802efa8f to your computer and use it in GitHub Desktop.
Hopscotch possible unit test for PR #89
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Starting at line 625 | |
it('Should recover gracefully from loss of sessionStorage', function(){ | |
if(!hasSessionStorage){ return; } | |
hopscotch.startTour({ | |
id: 'hopscotch-test-tour-sessionStorage', | |
steps: [ | |
{ | |
target: 'shopping-list', | |
orientation: 'left', | |
title: 'Shopping List', | |
content: 'It\'s a shopping list' | |
}, | |
{ | |
target: 'shopping-list', | |
orientation: 'left', | |
title: 'Shopping List', | |
content: 'It\'s a shopping list' | |
} | |
], | |
skipIfNoElement: false | |
}); | |
expect(getState('hopscotch.tour.state')).to.be('hopscotch-test-tour-sessionStorage:0'); | |
sinon.stub(sessionStorage, 'setItem', function(){ | |
throw new Error('Session Storage is full!'); | |
}); | |
hopscotch.nextStep(); | |
expect(sessionStorage.setItem.calledOnce).to.be.ok(); | |
expect(getState('hopscotch.tour.state')).to.not.be.ok(); | |
expect(getState('hopscotch.tour.state', true)).to.be('hopscotch-test-tour-sessionStorage:1'); | |
clearState('hopscotch.tour.state'); | |
sessionStorage.setItem.restore(); | |
hopscotch.endTour(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment