aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/tests/specs/jquery.placeholderSpec.js
blob: 436defdd70303c951b0a2e7fed58fdd1bcb04194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
 * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

describe('jquery.placeholder tests', function() {

	var $div;

	beforeEach(function() {
		$('#testArea').append($('<div id="placeholderdiv">'));
		$div = $('#placeholderdiv');
	});

	afterEach(function() {
		$div.remove();
	});

	describe('placeholder text', function() {
		it('shows one first letter if one word in a input text', function() {
			spyOn($div, 'html');
			$div.imageplaceholder('Seed', 'Name')
			expect($div.html).toHaveBeenCalledWith('N');
		});

		it('shows two first letters if two words in a input text', function() {
			spyOn($div, 'html');
			$div.imageplaceholder('Seed', 'First Second')
			expect($div.html).toHaveBeenCalledWith('FS');
		});

		it('shows two first letters if more then two words in a input text', function() {
			spyOn($div, 'html');
			$div.imageplaceholder('Seed', 'First Second Middle')
			expect($div.html).toHaveBeenCalledWith('FS');
		});
	});
});