From 5fd829aa092694b069f0b10725fc00e4eb0c1946 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 5 Apr 2021 12:50:23 +0200 Subject: [PATCH] adding unit tests for TopNav.resetInput(), triggering bug described in #682 --- js/test/TopNav.js | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/js/test/TopNav.js b/js/test/TopNav.js index e5a29c4..314d5ce 100644 --- a/js/test/TopNav.js +++ b/js/test/TopNav.js @@ -317,6 +317,92 @@ describe('TopNav', function () { ); }); + describe('resetInput', function () { + before(function () { + cleanup(); + }); + + it( + 'reset inputs to defaults (options off)', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + !$.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + !$.PrivateBin.TopNav.getOpenDiscussion() + ); + $('#burnafterreading').attr('checked', 'checked'); + $('#opendiscussion').attr('checked', 'checked'); + results.push( + $.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + $.PrivateBin.TopNav.getOpenDiscussion() + ); + $.PrivateBin.TopNav.resetInput(); + results.push( + !$.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + !$.PrivateBin.TopNav.getOpenDiscussion() + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + + it( + 'reset inputs to defaults (options on)', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + $.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + $.PrivateBin.TopNav.getOpenDiscussion() + ); + $('#burnafterreading').removeAttr('checked'); + $('#opendiscussion').removeAttr('checked'); + results.push( + !$.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + !$.PrivateBin.TopNav.getOpenDiscussion() + ); + $.PrivateBin.TopNav.resetInput(); + results.push( + $.PrivateBin.TopNav.getBurnAfterReading() + ); + results.push( + $.PrivateBin.TopNav.getOpenDiscussion() + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + }); + describe('getExpiration', function () { before(function () { cleanup();