diff --git a/test/spec/app.js b/test/spec/app.js new file mode 100644 index 0000000000..6567bf9ef6 --- /dev/null +++ b/test/spec/app.js @@ -0,0 +1,36 @@ +'use strict'; + +describe('AppJS', function() { + describe('Automatic page refresh', function(){ + var clock; + beforeEach(function () { + clock = sinon.useFakeTimers(); + sinon.stub(window, "refresher", function(){return true}); + }); + + afterEach(function () { + clock.restore(); + window.refresher.restore(); + }); + + it('should not call refresher if idle time is less than 6 hours', function() { + window.awaitIdle(); + clock.tick(21599999); + expect(window.refresher).to.not.be.called; + }); + + it('should not call refresher if awaitIdle is called within 6 hours', function() { + window.awaitIdle(); + clock.tick(21500000); + window.awaitIdle(); + clock.tick(21500000); + expect(window.refresher).to.not.be.called; + }); + + it('should call refresher if idle time is 6 hours or greater', function() { + window.awaitIdle(); + clock.tick(21600000); + expect(window.refresher).to.be.called; + }); + }); +});