jquery.placeholderSpec.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. describe('jquery.placeholder tests', function() {
  6. var $div;
  7. beforeEach(function() {
  8. $('#testArea').append($('<div id="placeholderdiv">'));
  9. $div = $('#placeholderdiv');
  10. });
  11. afterEach(function() {
  12. $div.remove();
  13. });
  14. describe('placeholder text', function() {
  15. it('shows one first letter if one word in a input text', function() {
  16. spyOn($div, 'html');
  17. $div.imageplaceholder('Seed', 'Name')
  18. expect($div.html).toHaveBeenCalledWith('N');
  19. });
  20. it('shows two first letters if two words in a input text', function() {
  21. spyOn($div, 'html');
  22. $div.imageplaceholder('Seed', 'First Second')
  23. expect($div.html).toHaveBeenCalledWith('FS');
  24. });
  25. it('shows two first letters if more then two words in a input text', function() {
  26. spyOn($div, 'html');
  27. $div.imageplaceholder('Seed', 'First Second Middle')
  28. expect($div.html).toHaveBeenCalledWith('FS');
  29. });
  30. });
  31. });