Memory.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. 'use strict';
  2. const common = require('../common');
  3. describe('Memory', function () {
  4. describe('add', function () {
  5. this.timeout(30000);
  6. jsc.property(
  7. 'allows adding valid paste URLs',
  8. common.jscSchemas(),
  9. jsc.nearray(common.jscA2zString()),
  10. jsc.array(common.jscQueryString()),
  11. 'string',
  12. function (schema, address, query, fragment) {
  13. const expected = schema + '://' + address.join('') + '/?' +
  14. encodeURI(
  15. query.join('').replace(/^&+|&+$/gm,'') + '#' + fragment
  16. ),
  17. clean = jsdom();
  18. $('body').html(
  19. '<main><div id="sidebar-wrapper"><table><tbody>' +
  20. '</tbody></table></div></main>'
  21. );
  22. // clear cache, then the first cell will match what we add
  23. $.PrivateBin.Memory.init();
  24. $.PrivateBin.Memory.add(expected);
  25. clean();
  26. return true;
  27. }
  28. );
  29. });
  30. describe('init', function () {
  31. it(
  32. 'enables toggling the memory sidebar',
  33. function() {
  34. $('body').html(
  35. '<main><div id="sidebar-wrapper"><table><tbody></tbody>' +
  36. '</table></div><button id="menu-toggle"></button></main>'
  37. );
  38. assert.ok(!$('main').hasClass('toggled'));
  39. $('#menu-toggle').click();
  40. assert.ok(!$('main').hasClass('toggled'));
  41. $.PrivateBin.Memory.init();
  42. assert.ok(!$('main').hasClass('toggled'));
  43. $('#menu-toggle').click();
  44. assert.ok($('main').hasClass('toggled'));
  45. $('#menu-toggle').click();
  46. assert.ok(!$('main').hasClass('toggled'));
  47. }
  48. );
  49. });
  50. });