Changeset 26976
- Timestamp:
- 01/17/2014 06:01:34 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/qunit/wp-includes/js/shortcode.js
r26222 r26976 5 5 test( 'next() should find the shortcode', function() { 6 6 var result; 7 7 8 8 // Basic 9 9 result = wp.shortcode.next( 'foo', 'this has the [foo] shortcode' ); … … 27 27 test( 'next() should find the shortcode when told to start looking beyond the start of the string', function() { 28 28 var result; 29 29 30 30 // Starting at indices 31 31 result = wp.shortcode.next( 'foo', 'this has the [foo] shortcode', 12 ); … … 79 79 test( 'replace() should replace the shortcode', function() { 80 80 var result; 81 81 82 82 // Basic 83 83 result = wp.shortcode.replace( 'foo', 'this has the [foo] shortcode', shortcodeReplaceCallback ); 84 84 equal( result, 'this has the bar shortcode', 'foo replaced with bar' ); 85 85 86 86 result = wp.shortcode.replace( 'foo', 'this has the [foo param="foo"] shortcode', shortcodeReplaceCallback ); 87 87 equal( result, 'this has the bar shortcode', 'foo and params replaced with bar' ); … … 112 112 test( 'replace() should not replace the escaped shortcodes', function() { 113 113 var result; 114 114 115 115 // Escaped 116 116 result = wp.shortcode.replace( 'foo', 'this has the [[foo]] shortcode', shortcodeReplaceCallback ); … … 135 135 }); 136 136 137 // A callback function for the replace tests 137 138 function shortcodeReplaceCallback( ) { 138 139 return 'bar'; 139 140 } 141 142 test( 'attrs() should return named attributes created with single, double, and no quotes', function() { 143 var expected = { 144 'named': { 145 'param': 'foo', 146 'another': 'bar', 147 'andagain': 'baz' 148 }, 'numeric' : [] 149 }; 150 151 deepEqual( wp.shortcode.attrs('param="foo" another=\'bar\' andagain=baz'), expected, 'attr parsed all three named types'); 152 }); 153 154 test( 'attrs() should return numeric attributes in the order they are used', function() { 155 var expected = { 156 'named': {}, 'numeric' : ['foo', 'bar', 'baz'] 157 }; 158 159 deepEqual( wp.shortcode.attrs('foo bar baz'), expected, 'attr parsed numeric attributes'); 160 }); 161 162 test( 'attrs() should return numeric attributes in the order they are used when they have named attributes in between', function() { 163 var expected = { 164 'named': { 'not': 'a blocker' }, 'numeric' : ['foo', 'bar', 'baz'] 165 }; 166 167 deepEqual( wp.shortcode.attrs('foo not="a blocker" bar baz'), expected, 'attr parsed numeric attributes'); 168 }); 140 169 });
Note: See TracChangeset
for help on using the changeset viewer.