Make WordPress Core

Ticket #26514: 26514.diff

File 26514.diff, 1.6 KB (added by jorbin, 11 years ago)
  • tests/qunit/wp-includes/js/shortcode.js

     
    134134                equal( result, 'this has the [foo] shortcode', 'stub not replaced' );
    135135        });
    136136
     137    // A callback function for the replace tests
    137138        function shortcodeReplaceCallback( ) {
    138139                return 'bar';
    139140        }
     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    });
    140169});