From 3538a8bec5043ae5b0ed3b46ebf2d7493d504d12 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 4 Mar 2018 14:55:18 +0100 Subject: [PATCH] concluding tests for TopNav --- js/test/TopNav.js | 136 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/js/test/TopNav.js b/js/test/TopNav.js index cbcef3c0..e83d5059 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)); + } + ); + }); });