Index: trunk/extensions/WebFonts/tests/qunit/ext.webfonts.tests.js |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | } ); |
9 | 9 | |
10 | 10 | test( '-- Web font application to body', function() { |
11 | | - expect( 4 ); |
| 11 | + expect( 17 ); |
12 | 12 | |
13 | 13 | var invalidFont = 'NonExistingFont'; |
14 | 14 | assertTrue( mw.webfonts.set( invalidFont ) === undefined, 'A non-existent font is not initialized' ); |
— | — | @@ -19,15 +19,35 @@ |
20 | 20 | fontFamily: $body.css( 'font-family' ), |
21 | 21 | fontSize: $body.css( 'font-size' ) |
22 | 22 | }; |
23 | | - var teluguFont = mw.webfonts.config.languages.te[0] |
| 23 | + var teluguFont = mw.webfonts.config.languages.te[0]; |
24 | 24 | $body.attr( 'lang', 'te' ); |
25 | 25 | |
| 26 | + ok( $( 'body' ).append( "<input class='webfonts-testing-element'>input content</input>"), 'An input element for testing was appended to body' ); |
| 27 | + $inputElement = $( 'input.webfonts-testing-element' ) |
| 28 | + assertTrue( $inputElement !== [], 'The input test element is defined' ); |
| 29 | + ok( $( 'body' ).append( "<select class='webfonts-testing-element'>select content</select>"), 'A select element for testing was appended to body' ); |
| 30 | + $selectElement = $( 'select.webfonts-testing-element' ) |
| 31 | + assertTrue( $selectElement !== [], 'The select test element is defined' ); |
| 32 | + ok( $( 'body' ).append( "<textarea class='webfonts-testing-element'>textarea content</textarea>"), 'A textarea element for testing was appended to body' ); |
| 33 | + $textareaElement = $( 'textarea.webfonts-testing-element' ) |
| 34 | + assertTrue( $textareaElement !== [], 'The textarea test element is defined' ); |
| 35 | + |
26 | 36 | ok( mw.webfonts.set( teluguFont ), 'Attempted to load a Telugu font for the whole page' ); |
| 37 | + var fallbackFonts = 'Helvetica,Arial,sans-serif'; |
27 | 38 | deepEqual( oldConfig, mw.webfonts.oldconfig, 'Previous body css was saved properly' ); |
28 | 39 | |
| 40 | + // Font application |
| 41 | + equal( $body.css( 'font-family' ), '"' + teluguFont + '",' + fallbackFonts, 'The web font was applied to font-family of body' ); |
| 42 | + equal( $inputElement.css( 'font-family' ), '"' + teluguFont + '",' + fallbackFonts, 'The web font was applied to font-family of input' ); |
| 43 | + equal( $selectElement.css( 'font-family' ), '"' + teluguFont + '",' + fallbackFonts, 'The web font was applied to font-family of select' ); |
| 44 | + equal( $textareaElement.css( 'font-family' ), '"' + teluguFont + '",' + fallbackFonts, 'The web font was applied to font-family of textarea' ); |
| 45 | + |
29 | 46 | // Restore <body> |
30 | 47 | $body.attr( 'lang', bodyLang ); |
31 | 48 | ok( mw.webfonts.reset(), 'Reset body after testing font application' ); |
| 49 | + ok( $inputElement.remove(), 'The input test element was removed from body' ); |
| 50 | + ok( $selectElement.remove(), 'The select test element was removed from body' ); |
| 51 | + ok( $textareaElement.remove(), 'The textarea test element was removed from body' ); |
32 | 52 | } ); |
33 | 53 | |
34 | 54 | test( '-- Dynamic font loading', function() { |