1 $(document).ready( function () {
2 module( "Toggle Switch" );
3 test( "Create", function () {
4 ok( $("#ts-auto").data("checked"), "should created by auto-intialization" );
5 $("#ts-self").toggleswitch();
6 ok( $("#ts-self").data("checked"), "should created by call '.toggleswitch()'" );
9 test( "Options", function () {
10 var ts = $("#ts-self"),
15 $("#ts-self").toggleswitch( {
20 deepEqual( [ on, off, false ],
21 [ ts.toggleswitch("option", "texton"),
22 ts.toggleswitch("option", "textoff"),
23 ts.toggleswitch("option", "checked") ],
24 "should set on/off text by option val" );
26 text.push( ts.next().find(".ui-toggleswitch-on .ui-toggleswitch-text").text() );
27 text.push( ts.next().find(".ui-toggleswitch-off .ui-toggleswitch-text").text() );
29 deepEqual( text, [ on, off ], "should display on/off text correctly" );
32 test( "Events", function () {
33 var ts = $("#ts-self").toggleswitch(),
34 before = ts.toggleswitch( "option", "checked" );
36 ts.bind("changed", function() {
37 ok( true, "should trigger changed event");
38 notEqual( before, ts.toggleswitch( "option", "checked" ), "should change value" );
41 // "click" event or ".click()" is not working due to 'remove 2nd vclick' patch.
42 ts.next().find(".ui-toggleswitch-mover").trigger( "vclick" );
45 before = ts.toggleswitch( "option", "checked" );
46 ts.toggleswitch( "option", "checked", !before );