jquery.placeholderSpec.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * Copyright (c) 2019 Serhii Shliakhov <shlyakhov.up@gmail.com>
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. describe('jquery.placeholder tests', function() {
  11. var $div;
  12. beforeEach(function() {
  13. $('#testArea').append($('<div id="placeholderdiv">'));
  14. $div = $('#placeholderdiv');
  15. });
  16. afterEach(function() {
  17. $div.remove();
  18. });
  19. describe('placeholder text', function() {
  20. it('shows one first letter if one word in a input text', function() {
  21. spyOn($div, 'html');
  22. $div.imageplaceholder('Seed', 'Name')
  23. expect($div.html).toHaveBeenCalledWith('N');
  24. });
  25. it('shows two first letters if two words in a input text', function() {
  26. spyOn($div, 'html');
  27. $div.imageplaceholder('Seed', 'First Second')
  28. expect($div.html).toHaveBeenCalledWith('FS');
  29. });
  30. it('shows two first letters if more then two words in a input text', function() {
  31. spyOn($div, 'html');
  32. $div.imageplaceholder('Seed', 'First Second Middle')
  33. expect($div.html).toHaveBeenCalledWith('FS');
  34. });
  35. });
  36. });