Index: trunk/extensions/Narayam/tests/qunit/ext.narayam.tests.js |
— | — | @@ -0,0 +1,64 @@ |
| 2 | +/** |
| 3 | + * QUnit tests for Narayam |
| 4 | + * |
| 5 | + * @file |
| 6 | + * @author Amir E. Aharoni |
| 7 | + * @copyright Copyright © 2012 Amir E. Aharoni |
| 8 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 9 | + */ |
| 10 | +( function () { |
| 11 | + |
| 12 | +module( "ext.narayam", QUnit.newMwEnvironment() ); |
| 13 | + |
| 14 | +var oldUserLang = mw.config.get( wgUserLanguage ); |
| 15 | +// A language that definitely has input methods |
| 16 | +mw.config.set( { wgUserLanguage: "ml" } ); |
| 17 | +$.narayam.setup(); |
| 18 | +$.narayam.enable(); |
| 19 | + |
| 20 | +test( "-- Initial check", function() { |
| 21 | + expect( 1 ); |
| 22 | + |
| 23 | + ok( $.narayam, "$.narayam is defined" ); |
| 24 | +} ); |
| 25 | + |
| 26 | +test( "-- Initialization functions", function() { |
| 27 | + expect( 10 ); |
| 28 | + |
| 29 | + var stateCookieName = "narayam-enabled"; |
| 30 | + |
| 31 | + // Now it's supposed to be enabled, so toggle() is supposed to disable. |
| 32 | + $.narayam.toggle(); |
| 33 | + equals( $.narayam.enabled(), false, "toggle() disables Narayam when it is enabled." ); |
| 34 | + equals( $.cookie( stateCookieName ), "0", "The state cookie was set to 0." ); |
| 35 | + ok( $( "li#pt-narayam" ).hasClass( "narayam-inactive" ), "After disabling the Narayam menu header has the narayam-inactive class." ); |
| 36 | + ok( !$( "li#pt-narayam" ).hasClass( "narayam-active" ), "After disabling the Narayam menu header doesn't have the narayam-active class ." ); |
| 37 | + ok( !$( "#narayam-toggle" ).attr( "checked" ), "After disabling the Narayam checkbox is not checked." ); |
| 38 | + |
| 39 | + // Now it's supposed to be disabled, so toggle() is supposed to enable. |
| 40 | + $.narayam.toggle(); |
| 41 | + equals( $.narayam.enabled(), true, "toggle() enables Narayam when it is disabled." ); |
| 42 | + equals( $.cookie( stateCookieName ), "1", "The state cookie was set to 1." ); |
| 43 | + ok( !$( "li#pt-narayam" ).hasClass( "narayam-inactive" ), "After enabling the Narayam menu header doesn't have the narayam-inactive class." ); |
| 44 | + ok( $( "li#pt-narayam" ).hasClass( "narayam-active" ), "After enabling the Narayam menu header has the narayam-active class ." ); |
| 45 | + ok( $( "#narayam-toggle" ).attr( "checked" ), "After enabling the Narayam checkbox is checked." ); |
| 46 | + |
| 47 | + |
| 48 | +} ); |
| 49 | + |
| 50 | +test( "-- Simple character functions", function() { |
| 51 | + expect( 7 ); |
| 52 | + |
| 53 | + equals( $.narayam.lastNChars( "foobarbaz", 5, 2 ), "ba", "lastNChars works with short buffer." ); |
| 54 | + equals( $.narayam.lastNChars( "foobarbaz", 2, 5 ), "fo", "lastNChars works with long buffer." ); |
| 55 | + |
| 56 | + equals( $.narayam.firstDivergence( "abc", "abc" ), -1 ); |
| 57 | + equals( $.narayam.firstDivergence( "a", "b" ), 0 ); |
| 58 | + equals( $.narayam.firstDivergence( "a", "bb" ), 0 ); |
| 59 | + equals( $.narayam.firstDivergence( "abc", "abd" ), 2 ); |
| 60 | + equals( $.narayam.firstDivergence( "abcd", "abd" ), 2 ); |
| 61 | +} ); |
| 62 | + |
| 63 | +mw.config.set( { wgUserLanguage: oldUserLang } ); |
| 64 | + |
| 65 | +}()); |
Property changes on: trunk/extensions/Narayam/tests/qunit/ext.narayam.tests.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 66 | + native |
Index: trunk/extensions/WebFonts/tests/qunit/ext.narayam.tests.js |
— | — | @@ -1,64 +0,0 @@ |
2 | | -/** |
3 | | - * QUnit tests for Narayam |
4 | | - * |
5 | | - * @file |
6 | | - * @author Amir E. Aharoni |
7 | | - * @copyright Copyright © 2012 Amir E. Aharoni |
8 | | - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
9 | | - */ |
10 | | -( function () { |
11 | | - |
12 | | -module( "ext.narayam", QUnit.newMwEnvironment() ); |
13 | | - |
14 | | -var oldUserLang = mw.config.get( wgUserLanguage ); |
15 | | -// A language that definitely has input methods |
16 | | -mw.config.set( { wgUserLanguage: "ml" } ); |
17 | | -$.narayam.setup(); |
18 | | -$.narayam.enable(); |
19 | | - |
20 | | -test( "-- Initial check", function() { |
21 | | - expect( 1 ); |
22 | | - |
23 | | - ok( $.narayam, "$.narayam is defined" ); |
24 | | -} ); |
25 | | - |
26 | | -test( "-- Initialization functions", function() { |
27 | | - expect( 10 ); |
28 | | - |
29 | | - var stateCookieName = "narayam-enabled"; |
30 | | - |
31 | | - // Now it's supposed to be enabled, so toggle() is supposed to disable. |
32 | | - $.narayam.toggle(); |
33 | | - equals( $.narayam.enabled(), false, "toggle() disables Narayam when it is enabled." ); |
34 | | - equals( $.cookie( stateCookieName ), "0", "The state cookie was set to 0." ); |
35 | | - ok( $( "li#pt-narayam" ).hasClass( "narayam-inactive" ), "After disabling the Narayam menu header has the narayam-inactive class." ); |
36 | | - ok( !$( "li#pt-narayam" ).hasClass( "narayam-active" ), "After disabling the Narayam menu header doesn't have the narayam-active class ." ); |
37 | | - ok( !$( "#narayam-toggle" ).attr( "checked" ), "After disabling the Narayam checkbox is not checked." ); |
38 | | - |
39 | | - // Now it's supposed to be disabled, so toggle() is supposed to enable. |
40 | | - $.narayam.toggle(); |
41 | | - equals( $.narayam.enabled(), true, "toggle() enables Narayam when it is disabled." ); |
42 | | - equals( $.cookie( stateCookieName ), "1", "The state cookie was set to 1." ); |
43 | | - ok( !$( "li#pt-narayam" ).hasClass( "narayam-inactive" ), "After enabling the Narayam menu header doesn't have the narayam-inactive class." ); |
44 | | - ok( $( "li#pt-narayam" ).hasClass( "narayam-active" ), "After enabling the Narayam menu header has the narayam-active class ." ); |
45 | | - ok( $( "#narayam-toggle" ).attr( "checked" ), "After enabling the Narayam checkbox is checked." ); |
46 | | - |
47 | | - |
48 | | -} ); |
49 | | - |
50 | | -test( "-- Simple character functions", function() { |
51 | | - expect( 7 ); |
52 | | - |
53 | | - equals( $.narayam.lastNChars( "foobarbaz", 5, 2 ), "ba", "lastNChars works with short buffer." ); |
54 | | - equals( $.narayam.lastNChars( "foobarbaz", 2, 5 ), "fo", "lastNChars works with long buffer." ); |
55 | | - |
56 | | - equals( $.narayam.firstDivergence( "abc", "abc" ), -1 ); |
57 | | - equals( $.narayam.firstDivergence( "a", "b" ), 0 ); |
58 | | - equals( $.narayam.firstDivergence( "a", "bb" ), 0 ); |
59 | | - equals( $.narayam.firstDivergence( "abc", "abd" ), 2 ); |
60 | | - equals( $.narayam.firstDivergence( "abcd", "abd" ), 2 ); |
61 | | -} ); |
62 | | - |
63 | | -mw.config.set( { wgUserLanguage: oldUserLang } ); |
64 | | - |
65 | | -}()); |