Merge branch 'sdk'
[platform/framework/web/web-ui-fw.git] / tests / unit-tests / pagecontrol / pagecontrol-tests.js
1 /**
2  * pagecontrol test
3  */
4 ( function ( $ ) {
5         $.mobile.defaultTransition = "none";
6
7         module( "PageControl" );
8
9         test( "Basic pagecontrol test", function ( ) {
10                 var pc = $( '<div data-role="pagecontrol"></div>' )
11                                 .attr( {
12                                 'data-max': 10,
13                                 'data-value': 2
14                                 } ),
15                         nb;
16
17                 pc.pagecontrol( );
18
19                 ok( pc, "pagecontrol object creation" );
20                 nb = pc.children( 'div.page_n' )[1];    // 2nd button
21                 console.dir( nb );
22                 ok( $(nb).hasClass( 'page_n_selected' ), "first button should be activated" );
23                 equal( $( pc ).pagecontrol( "value" ), 2, "value() method must return 2" );
24
25                 nb = pc.children( 'div.page_n' )[9];
26                 ok( nb, "last number button should exist" );
27                 pc.one( "change", function( ev, val ) {
28                         equal( val, 10, "pagecontrol element's value must be set when click event comes." );
29                         ok( $( nb ).hasClass( 'page_n_selected' ), "after click, clicked button should be changed to number type" );
30                         equal( $( pc ).pagecontrol( "value" ), 10, "value() method must return 10" );
31
32                         $( pc ).pagecontrol( "value", 5 );
33                         equal( $( pc ).pagecontrol( "value" ), 5, "value() method must return 5 after running .value(5)" );
34
35                         } );
36                 $(nb).trigger( "click" );
37         } );
38
39 } ) ( jQuery );
40