Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6335: string.html.diff

File string.html.diff, 2.5 kB (added by Tobie, 3 years ago)

tests

  • test/unit/string.html

    old new  
    127127      assertEqual('classNameTest','class-nameTest'.camelize()); 
    128128    }}, 
    129129     
     130    testCapitalize: function() {with(this) { 
     131      assertEqual('Hello','hello'.capitalize()); 
     132      assertEqual('Hello','HELLO'.capitalize()); 
     133      assertEqual('Hello','Hello'.capitalize()); 
     134      assertEqual('Hello','hELLO'.capitalize()); 
     135      assertEqual('Hello world','hello world'.capitalize()); 
     136    }},     
     137     
    130138    testTruncate: function() {with(this) { 
    131139      var source = 'foo boo boz foo boo boz foo boo boz foo boo boz'; 
    132140      assertEqual(source, source.truncate(source.length)); 
     
    142150      assertEqual('', ' '.strip()); 
    143151    }}, 
    144152     
     153    testSqueeze: function() {with(this) { 
     154      assertEqual('a', 'a'.squeeze()); 
     155      assertEqual('helo world!', 'hellllllooooo   woooooooorrld!!!!'.squeeze()); 
     156      assertEqual('hello world', 'hello world'.squeeze('')); 
     157      assertEqual('hello world', 'hello     world'.squeeze(' ')); 
     158      assertEqual('hello \n world', 'hello   \n     world'.squeeze(' ')); 
     159      assertEqual('hello world.', 'hello world...'.squeeze('.')); 
     160      assertEqual('hello world', 'hello world'.squeeze('v')); 
     161      assertEqual('helo world.', 'hellllllo world...'.squeeze('.l')); 
     162      assertEqual('helo world.', 'hellllllo world...'.squeeze('l.v')); 
     163      assertEqual('hello world...', 'hello worrrrrld...'.squeeze('q-z')); 
     164      assertEqual('hello-world.', 'hello-------world...'.squeeze('.-')); 
     165      assertEqual('hello\\', 'hello\\\\\\\\\\\\\\\\\\'.squeeze('\\')); 
     166      assertEqual('hello^', 'hello^^^^^^^^^'.squeeze('^')); 
     167      assertEqual('\t', '\t\t\t\t'.squeeze('    ')); 
     168      assertEqual('', ''.squeeze()); 
     169    }},   
     170     
     171    testStripLineBreaks: function() {with(this) { 
     172      assertEqual('hello world', 'hello world'.stripLineBreaks()); 
     173      assertEqual('hello  world', 'hello\n world'.stripLineBreaks()); 
     174      assertEqual('hello  world', 'hello\r world'.stripLineBreaks()); 
     175      assertEqual('hello  world', 'hello\r\n world'.stripLineBreaks()); 
     176      assertEqual('hello   world', 'hello \r\n\r\n\r\r\n\r\n\r\n world'.stripLineBreaks()); 
     177    }},    
     178          
    145179    testStripTags: function() {with(this) { 
    146180      assertEqual('hello world', 'hello world'.stripTags()); 
    147181      assertEqual('hello world', 'hello <span>world</span>'.stripTags());