1
0

Prompt.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. require('../common');
  3. describe('Prompt', function () {
  4. // TODO: this does not test the prompt() fallback, since that isn't available
  5. // in nodejs -> replace the prompt in the "page" template with a modal
  6. describe('requestPassword & getPassword', function () {
  7. this.timeout(30000);
  8. jsc.property(
  9. 'returns the password fed into the dialog',
  10. 'string',
  11. function (password) {
  12. password = password.replace(/\r+/g, '');
  13. var clean = jsdom('', {url: 'ftp://example.com/?0000000000000000'});
  14. $('body').html(
  15. '<div id="passwordmodal" class="modal fade" role="dialog">' +
  16. '<div class="modal-dialog"><div class="modal-content">' +
  17. '<div class="modal-body"><form id="passwordform" role="form">' +
  18. '<div class="form-group"><input id="passworddecrypt" ' +
  19. 'type="password" class="form-control" placeholder="Enter ' +
  20. 'password"></div><button type="submit">Decrypt</button>' +
  21. '</form></div></div></div></div>'
  22. );
  23. $.PrivateBin.Model.reset();
  24. $.PrivateBin.Model.init();
  25. $.PrivateBin.Prompt.init();
  26. $.PrivateBin.Prompt.requestPassword();
  27. $('#passworddecrypt').val(password);
  28. // TODO triggers error messages in current jsDOM version, find better solution
  29. //$('#passwordform').submit();
  30. //var result = $.PrivateBin.Prompt.getPassword();
  31. var result = $('#passworddecrypt').val();
  32. $.PrivateBin.Model.reset();
  33. clean();
  34. return result === password;
  35. }
  36. );
  37. });
  38. });