aboutsummaryrefslogtreecommitdiff
blob: d6d62fc867bb112fd5005b2bb37a7732b207af42 (plain) (blame)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<pre id="sh_011_smart_tabs_a" class="brush: plain;">
	the		words	in		this	paragraph
	should	look	like	they	are
	evenly	spaced	between	columns
</pre>

<pre id="sh_011_smart_tabs_b" class="brush: plain; tab-size: 8;">
	the	words	in	this	paragraph
	should	look	like	they	are
	evenly	spaced	between	columns
</pre>

<pre id="sh_011_smart_tabs_c" class="brush: plain; smart-tabs: false">
	the		words	in		this	paragraph
	should	look	out		of		whack
	because	smart	tabs	are		disabled
</pre>

<script type="text/javascript">
queue(function()
{
	var $sh;
	
	module('011_smart_tabs');
	
	var evenLines = [
			'the     words   in      this    paragraph',
			'should  look    like    they    are',
			'evenly  spaced  between columns'
		],
		unevenLines = [
			'the        words    in        this    paragraph',
			'should    look    out        of        whack',
			'because    smart    tabs    are        disabled'
		]
		;
		
	function fixSpaces(s)
	{
		s = encodeURIComponent(s).replace(/%C2%A0/g, '%20');
		return unescape(s).replace(/\s+$/g, '');
	};
	
	test('default tab size is 4', function()
	{
		$sh = $('#sh_011_smart_tabs_a');
		
		ok_sh($sh);
		ok_toolbar($sh);
		ok_code($sh);
		
		$sh.find('.code .line').each(function(index)
		{
			var s1 = fixSpaces($(this).text()),
				s2 = fixSpaces(evenLines[index])
				;
				
			equal(s1, s2, 'Line ' + index);
		});
	});

	test('tab size changed to 8', function() 
	{
		$sh = $('#sh_011_smart_tabs_b');
		
		ok_sh($sh);
		ok_toolbar($sh);
		ok_code($sh);
		
		$sh.find('.code .line').each(function(index)
		{
			var s1 = fixSpaces($(this).text()),
				s2 = fixSpaces(evenLines[index])
				;
				
			equal(s1, s2, 'Line ' + index);
		});
	});
	
	test('smart tabs are off', function() 
	{
		$sh = $('#sh_011_smart_tabs_c');
		
		ok_sh($sh);
		ok_toolbar($sh);
		ok_code($sh);
		
		$sh.find('.code .line').each(function(index)
		{
			var s1 = fixSpaces($(this).text()),
				s2 = fixSpaces(unevenLines[index])
				;
				
			equal(s1, s2, 'Line ' + index);
		});
	});
});
</script>
Powered by cgit v1.2.3 (git 2.41.0)