Export 0.1.63
[platform/framework/web/web-ui-fw.git] / tests / unit-tests / toggleswitch / toggleswitch-tests.js
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()'" );
7         });
8
9         test( "Options", function () {
10                 var ts = $("#ts-self"),
11                         text = [],
12                         on = "Enable",
13                         off = "Disable";
14
15                 $("#ts-self").toggleswitch( {
16                         texton: on,
17                         textoff: off,
18                         checked: false
19                 });
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" );
25
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() );
28
29                 deepEqual( text, [ on, off ], "should display on/off text correctly" );
30         });
31
32         test( "Events", function () {
33                 var ts = $("#ts-self").toggleswitch(),
34                         before = ts.toggleswitch( "option", "checked" );
35
36                 ts.bind("change", function() {
37                         ok( true, "should trigger change event");
38                         notEqual( before, ts.toggleswitch( "option", "checked" ), "should change value" );
39                 });
40
41                 // "click" event or ".click()" is not working due to 'remove 2nd vclick' patch.
42                 ts.next().find(".ui-toggleswitch-mover").trigger( "vclick" );
43                 expect(2);
44
45                 before = ts.toggleswitch( "option", "checked" );
46                 ts.toggleswitch( "option", "checked", !before );
47
48                 expect(4);
49         });
50
51 });