PageRenderTime 25ms CodeModel.GetById 19ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/pigeoncms/Plugins/syntaxhighlighter/tests/cases/011_smart_tabs.html

http://pigeoncms.googlecode.com/
HTML | 98 lines | 80 code | 18 blank | 0 comment | 0 complexity | 3d2a9cdf01efb438fc51db11f0f71e69 MD5 | raw file
 1<pre id="sh_011_smart_tabs_a" class="brush: plain;">
 2	the		words	in		this	paragraph
 3	should	look	like	they	are
 4	evenly	spaced	between	columns
 5</pre>
 6
 7<pre id="sh_011_smart_tabs_b" class="brush: plain; tab-size: 8;">
 8	the	words	in	this	paragraph
 9	should	look	like	they	are
10	evenly	spaced	between	columns
11</pre>
12
13<pre id="sh_011_smart_tabs_c" class="brush: plain; smart-tabs: false">
14	the		words	in		this	paragraph
15	should	look	out		of		whack
16	because	smart	tabs	are		disabled
17</pre>
18
19<script type="text/javascript">
20queue(function()
21{
22	var $sh;
23	
24	module('011_smart_tabs');
25	
26	var evenLines = [
27			'the     words   in      this    paragraph',
28			'should  look    like    they    are',
29			'evenly  spaced  between columns'
30		],
31		unevenLines = [
32			'the        words    in        this    paragraph',
33			'should    look    out        of        whack',
34			'because    smart    tabs    are        disabled'
35		]
36		;
37		
38	function fixSpaces(s)
39	{
40		s = encodeURIComponent(s).replace(/%C2%A0/g, '%20');
41		return unescape(s).replace(/\s+$/g, '');
42	};
43	
44	test('default tab size is 4', function()
45	{
46		$sh = $('#sh_011_smart_tabs_a');
47		
48		ok_sh($sh);
49		ok_toolbar($sh);
50		ok_code($sh);
51		
52		$sh.find('.code .line').each(function(index)
53		{
54			var s1 = fixSpaces($(this).text()),
55				s2 = fixSpaces(evenLines[index])
56				;
57				
58			equal(s1, s2, 'Line ' + index);
59		});
60	});
61
62	test('tab size changed to 8', function() 
63	{
64		$sh = $('#sh_011_smart_tabs_b');
65		
66		ok_sh($sh);
67		ok_toolbar($sh);
68		ok_code($sh);
69		
70		$sh.find('.code .line').each(function(index)
71		{
72			var s1 = fixSpaces($(this).text()),
73				s2 = fixSpaces(evenLines[index])
74				;
75				
76			equal(s1, s2, 'Line ' + index);
77		});
78	});
79	
80	test('smart tabs are off', function() 
81	{
82		$sh = $('#sh_011_smart_tabs_c');
83		
84		ok_sh($sh);
85		ok_toolbar($sh);
86		ok_code($sh);
87		
88		$sh.find('.code .line').each(function(index)
89		{
90			var s1 = fixSpaces($(this).text()),
91				s2 = fixSpaces(unevenLines[index])
92				;
93				
94			equal(s1, s2, 'Line ' + index);
95		});
96	});
97});
98</script>