This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
/
flipswitch_core.js
70 lines (68 loc) · 3.28 KB
/
flipswitch_core.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* mobile flipswitch unit tests
*/
(function($){
test( "checkbox based flipswitch is enhanced", function() {
ok( $("#flip-checkbox").parent().hasClass("ui-flipswitch"), "should be enhanced" );
});
test( "select based flipswitch is enhanced", function() {
ok( $("#flip-select").parent().hasClass("ui-flipswitch"), "should be enhanced" );
});
test( "checkbox based flipswitch is disabled", function() {
ok( $("#flip-checkbox-disabled").parent().hasClass("ui-state-disabled"), "should be disabled" );
});
test( "select based flipswitch is disabled", function() {
ok( $("#flip-select-disabled").parent().hasClass("ui-state-disabled"), "should be disabled" );
});
test( "checkbox based flipswitch is active", function() {
ok( $("#flip-checkbox-active").parent().hasClass("ui-flipswitch-active"), "should be active" );
});
test( "select based flipswitch is active", function() {
ok( $("#flip-select-second-option").parent().hasClass("ui-flipswitch-active"), "should be active" );
});
test( "checkbox based flipswitch is mini", function() {
ok( $("#flip-checkbox-mini").parent().hasClass("ui-mini"), "should be mini" );
});
test( "select based flipswitch is mini", function() {
ok( $("#flip-select-mini").parent().hasClass("ui-mini"), "should be mini" );
});
test( "checkbox based flipswitch should have theme inherit", function() {
ok( $("#flip-checkbox-active").parent().hasClass("ui-bar-inherit"), "should be inherit theme" );
});
test( "select based flipswitch should have theme inherit", function() {
ok( $("#flip-select-second-option").parent().hasClass("ui-bar-inherit"), "should be inherit theme" );
});
test( "checkbox based flipswitch is toggled on click", function() {
ok( !$("#flip-checkbox").parent().hasClass("ui-flipswitch-active"), "should not be active" );
$("#flip-checkbox").parent().click()
ok( $("#flip-checkbox").parent().hasClass("ui-flipswitch-active"), "should be active" );
});
test( "select based flipswitch is toggled on click", function() {
$("#flip-select").click();
ok( $("#flip-select").parent().hasClass("ui-flipswitch-active"), "should be active" );
});
test( "checkbox based flipswitch is not active after left swipe", function() {
$("#flip-checkbox").trigger("swipeleft");
ok( !$("#flip-checkbox").parent().hasClass("ui-flipswitch-active"), "should be active" );
});
test( "select based flipswitch is not active after left swipe", function() {
$("#flip-select").trigger("swipeleft");
ok( !$("#flip-select").parent().hasClass("ui-flipswitch-active"), "should be active" );
});
test( "checkbox based flipswitch is active after right swipe", function() {
$("#flip-checkbox").trigger("swiperight");
ok( $("#flip-checkbox").parent().hasClass("ui-flipswitch-active"), "should not be active" );
});
test( "select based flipswitch is active after right swipe", function() {
$("#flip-select").trigger("swiperight");
ok( $("#flip-select").parent().hasClass("ui-flipswitch-active"), "should not be active" );
});
test( "checkbox based flipswitch is untabbable", function() {
deepEqual( parseInt( $( "#flip-checkbox" ).attr( "tabindex" ) ), -1,
"tabindex is set to -1" );
});
test( "select based flipswitch is untabbable", function() {
deepEqual( parseInt( $( "#flip-select" ).attr( "tabindex" ) ), -1,
"tabindex is set to -1" );
});
})( jQuery );