diff --git a/js/test/TopNav.js b/js/test/TopNav.js index cbcef3c..e83d505 100644 --- a/js/test/TopNav.js +++ b/js/test/TopNav.js @@ -408,5 +408,141 @@ describe('TopNav', function () { } ); }); + + describe('getBurnAfterReading', function () { + before(function () { + cleanup(); + }); + + it( + 'returns if the burn-after-reading checkbox was ticked', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + !$.PrivateBin.TopNav.getBurnAfterReading() + ); + $('#burnafterreading').attr('checked', 'checked'); + results.push( + $.PrivateBin.TopNav.getBurnAfterReading() + ); + $('#burnafterreading').removeAttr('checked'); + results.push( + !$.PrivateBin.TopNav.getBurnAfterReading() + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + }); + + describe('getOpenDiscussion', function () { + before(function () { + cleanup(); + }); + + it( + 'returns if the open-discussion checkbox was ticked', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + !$.PrivateBin.TopNav.getOpenDiscussion() + ); + $('#opendiscussion').attr('checked', 'checked'); + results.push( + $.PrivateBin.TopNav.getOpenDiscussion() + ); + $('#opendiscussion').removeAttr('checked'); + results.push( + !$.PrivateBin.TopNav.getOpenDiscussion() + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + }); + + + describe('getPassword', function () { + before(function () { + cleanup(); + }); + + jsc.property( + 'returns the contents of the password input', + 'string', + function (password) { + password = password.replace(/\r+/g, ''); + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + $.PrivateBin.TopNav.getPassword() === '' + ); + $('#passwordinput').val(password); + results.push( + $.PrivateBin.TopNav.getPassword() === password + ); + $('#passwordinput').val(''); + results.push( + $.PrivateBin.TopNav.getPassword() === '' + ); + cleanup(); + return results.every(element => element); + } + ); + }); + + describe('getCustomAttachment', function () { + before(function () { + cleanup(); + }); + + it( + 'returns the custom attachment element', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + !$.PrivateBin.TopNav.getCustomAttachment().hasClass('test') + ); + $('#customattachment').addClass('test'); + results.push( + $.PrivateBin.TopNav.getCustomAttachment().hasClass('test') + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + }); });