annotate .svn/pristine/54/549732f3fd96b4524d8aa62cc5177f9b0ad9d268.svn-base @ 1327:287f201c2802 redmine-2.2-integration

Add italic
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 19 Jun 2013 20:56:22 +0100
parents cbb26bc654de
children
rev   line source
Chris@909 1 # encoding: utf-8
Chris@909 2 #
Chris@909 3 # Redmine - project management software
Chris@909 4 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@909 5 #
Chris@909 6 # This program is free software; you can redistribute it and/or
Chris@909 7 # modify it under the terms of the GNU General Public License
Chris@909 8 # as published by the Free Software Foundation; either version 2
Chris@909 9 # of the License, or (at your option) any later version.
Chris@909 10 #
Chris@909 11 # This program is distributed in the hope that it will be useful,
Chris@909 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@909 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@909 14 # GNU General Public License for more details.
Chris@909 15 #
Chris@909 16 # You should have received a copy of the GNU General Public License
Chris@909 17 # along with this program; if not, write to the Free Software
Chris@909 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@909 19
Chris@909 20 require File.expand_path('../../../test_helper', __FILE__)
Chris@909 21
Chris@909 22 class SearchHelperTest < ActionView::TestCase
Chris@909 23 include SearchHelper
Chris@909 24
Chris@909 25 def test_highlight_single_token
Chris@909 26 assert_equal 'This is a <span class="highlight token-0">token</span>.',
Chris@909 27 highlight_tokens('This is a token.', %w(token))
Chris@909 28 end
Chris@909 29
Chris@909 30 def test_highlight_multiple_tokens
Chris@909 31 assert_equal 'This is a <span class="highlight token-0">token</span> and <span class="highlight token-1">another</span> <span class="highlight token-0">token</span>.',
Chris@909 32 highlight_tokens('This is a token and another token.', %w(token another))
Chris@909 33 end
Chris@909 34
Chris@909 35 def test_highlight_should_not_exceed_maximum_length
Chris@909 36 s = (('1234567890' * 100) + ' token ') * 100
Chris@909 37 r = highlight_tokens(s, %w(token))
Chris@909 38 assert r.include?('<span class="highlight token-0">token</span>')
Chris@909 39 assert r.length <= 1300
Chris@909 40 end
Chris@909 41
Chris@909 42 def test_highlight_multibyte
Chris@909 43 s = ('й' * 200) + ' token ' + ('й' * 200)
Chris@909 44 r = highlight_tokens(s, %w(token))
Chris@909 45 assert_equal ('й' * 45) + ' ... ' + ('й' * 44) + ' <span class="highlight token-0">token</span> ' + ('й' * 44) + ' ... ' + ('й' * 45), r
Chris@909 46 end
Chris@909 47 end