From f5f12834f6daee2da68650f6196881ba760df420 Mon Sep 17 00:00:00 2001 From: Krinkle Date: Mon, 5 Sep 2011 21:25:48 +0000 Subject: [PATCH] mediawiki.html: Add broken tests for numbers and booleans * The following are broken right now: mw.html.element( 'p', {}, 500 ); > Error: mw.html.element: Invalid type of contents (custom error by mw.html.element) mw.html.element( 'option', { selected: foo === bar }, 'label' ); > TypeError: Undefined method .replace (bug 30774) - mediawiki.html: Add support for numbers and booleans --- .../resources/mediawiki/mediawiki.test.js | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.test.js index eb6ee2aa86..1220ce12f1 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.test.js @@ -170,7 +170,7 @@ test( 'mw.loader.bug29107' , function() { }); test( 'mw.html', function() { - expect(7); + expect(11); raises( function(){ mw.html.escape(); @@ -184,11 +184,41 @@ test( 'mw.html', function() { equal( mw.html.element( 'div' ), '
', 'html.element DIV (simple)' ); - equal( mw.html.element( 'div', - { id: 'foobar' } ), + equal( + mw.html.element( + 'div', { + id: 'foobar' + } + ), '
', 'html.element DIV (attribs)' ); + equal( mw.html.element( 'p', null, 12 ), '

12

', 'Numbers are valid content and should be casted to a string' ); + + equal( mw.html.element( 'p', { title: 12 }, '' ), '

', 'Numbers are valid attribute values' ); + + equal( + mw.html.element( + 'option', { + value: 'foo', + selected: true + }, 'Foo' + ), + '', + 'Attributes may have boolean values. True copies the attribute name to the value.' + ); + + equal( + mw.html.element( + 'option', { + value: 'foo', + selected: false + }, 'Foo' + ), + '', + 'Attributes may have boolean values. False keeps the attribute from output.' + ); + equal( mw.html.element( 'div', null, 'a' ), '
a
', -- 2.20.1