| | 167 | test( 'replace() replaces the shortcode with `0` when the callback returns `0`', function() { |
| | 168 | var result = wp.shortcode.replace( 'foo', 'this has the [foo]shortcode[/foo]', function() { |
| | 169 | return 0; |
| | 170 | } ); |
| | 171 | |
| | 172 | equal( result, 'this has the 0', 'shortcode not replaced with `0`' ); |
| | 173 | }); |
| | 174 | |
| | 175 | test( 'replace() removes the shortcode and shortcode content when the callback returns `null`', function() { |
| | 176 | var result = wp.shortcode.replace( 'foo', 'this has the [foo]shortcode[/foo]', function() { |
| | 177 | return null; |
| | 178 | } ); |
| | 179 | |
| | 180 | equal( result, 'this has the ', 'shortcode and shortcode content not removed' ); |
| | 181 | }); |
| | 182 | |
| | 183 | test( 'replace() removes the shortcode and shortcode content when the callback returns `false`', function() { |
| | 184 | var result = wp.shortcode.replace( 'foo', 'this has the [foo]shortcode[/foo]', function() { |
| | 185 | return false; |
| | 186 | } ); |
| | 187 | |
| | 188 | equal( result, 'this has the ', 'shortcode and shortcode content not removed' ); |
| | 189 | }); |
| | 190 | |
| | 191 | test( 'replace() removes the shortcode and shortcode content when the callback returns `undefined`', function() { |
| | 192 | var result = wp.shortcode.replace( 'foo', 'this has the [foo]shortcode[/foo]', function() { |
| | 193 | return undefined; |
| | 194 | } ); |
| | 195 | |
| | 196 | equal( result, 'this has the ', 'shortcode and shortcode content not removed' ); |
| | 197 | }); |
| | 198 | |
| | 199 | test( 'replace() removes the shortcode and shortcode content when the callback returns an empty string', function() { |
| | 200 | var result = wp.shortcode.replace( 'foo', 'this has the [foo]shortcode[/foo]', function() { |
| | 201 | return ''; |
| | 202 | } ); |
| | 203 | |
| | 204 | equal( result, 'this has the ', 'shortcode and shortcode content not removed' ); |
| | 205 | }); |
| | 206 | |