2.0_beta sync to rsa
[framework/web/web-ui-fw.git] / tests / unit-tests / swipelist / swipelist-tests.js
1 /*
2  * swipelist unit tests
3  *
4  * Hyunjung Kim <hjnim.kim@samsung.com>
5  *
6  */
7
8 ( function ( $ ) {
9
10         module("swipelist");
11
12         var unit_swipe = function( swipelist, type ) {
13                 var     covers,
14                         cover,
15                         coverStart,
16                         item,
17                         slideLeftDone = function () {
18                                 ok(true, "Animation Complete - sliding left");
19                                 cover.unbind("animationComplete");
20                                 equal(cover.position().left, coverStart, "Position - Cover");
21                                 start();
22                         },
23                         slideRightDone = function () {
24                                 ok(true, "Animation Complete - sliding right");
25                                 setTimeout(function () {
26                                         cover.unbind("animationComplete");
27                                         cover.bind("animationComplete", slideLeftDone);
28                                         item.trigger("swipeleft");
29                                 }, 0);
30                         };
31
32                 $("#swipelistpage").page();
33                 swipelist.swipelist();
34
35                 ok(swipelist.hasClass("ui-swipelist"),"Create - Swipelist");
36                 covers = swipelist.find("li *.ui-swipelist-item-cover");
37                 cover = covers.first();
38                 coverStart = cover.position().left;
39                 item = swipelist.find("li").first();
40
41                 cover.bind("animationComplete", slideRightDone);
42                 cover.trigger("swiperight");
43                 stop();
44
45                 equal( swipelist.find("li.ui-swipelist-item").length , 2, "Count - Swipeable li");
46                 equal( covers.length , 2, "Count - cover");
47
48                 equal(covers.find("span.ui-swipelist-item-cover-inner:contains('1line-leftsub1')").length,
49                                 1,
50                                 "Check - Cover string value");
51         };
52
53         var unit_swipe_destroy = function(swipelist, type) {
54                 var covers,
55                         new_page = $("#swipedestorypage");
56
57                 new_page.page();
58                 swipelist.swipelist();
59                 ok(swipelist.hasClass("ui-swipelist"),"Create - Swipelist");
60                 covers = swipelist.find("li *.ui-swipelist-item-cover");
61
62                 equal( swipelist.find("li.ui-swipelist-item").length , 2, "Count - Swipeable li");
63                 equal( covers.length , 2, "Count - cover");
64
65                 swipelist.swipelist("destroy");
66
67                 equal(new_page.has('.ui-swipelist').length, 0, "Destroy - list");
68                 equal(new_page.has('.ui-swipelist-item').length, 0 , "Destroy - item" );
69                 equal(new_page.has('.ui-swipelist-item-cover').length, 0, "Destroy - cover");
70
71         };
72
73         asyncTest( " swipelist ", function() {
74                 expect(7);
75                 unit_swipe( $("#swipewidget"), "swipelist" );
76                 start();
77         });
78
79         asyncTest( " swipelist - destory", function() {
80                 expect(6),
81                 unit_swipe_destroy( $("#swipedestroy"), "swipelistdestroy"),
82                 start()
83         });
84
85 } ) ( jQuery );