2 * Unit Test : Notification
4 * Minkyu Kang <mk7.kang@samsung.com>
6 /*jslint browser: true*/
7 /*global $, jQuery, test, equal, ok*/
9 module("Notification");
11 var unit_notification = function ( widget, type ) {
18 widget.notification();
20 notification = widget.children( elem );
21 ok( notification, "Create");
24 if (type == ' ticker') {
25 ok(notification.find('.ui-ticker-btn'), "makrup Check : Close button") ;
26 ok(notification.find('.ui-ticker-btn').find(":jqmData(role=button)"), "makrup Check : Close button present") ;
27 equal(notification.find('.ui-ticker-btn').find(":jqmData(role=button)").text(), 'Close', "makrup Check : Close button text") ;
28 ok(notification.find('.ui-ticker').find(".ui.ticker-text1-bg"), "makrup Check : ticker text present") ;
29 ok(notification.find('.ui-ticker').find(".ui.ticker-text2-bg"), "makrup Check : ticker text present") ;
30 ok(notification.find('.ui-ticker').find("img.ui-ticker-icon").length > 0, "makrup Check : ticker icon present") ;
32 ok(notification.find('.ui-smallpopup'), "makrup Check : smapll popup") ;
33 ok(notification.find('.ui-smallpopup').find(".ui.smallpopup-text-bg"), "makrup Check : popup text present") ;
37 widget.notification("open");
38 notification = widget.children( elem );
39 ok( notification.hasClass("show"), "API : open");
42 widget.notification("close");
43 notification = widget.children( elem );
44 ok( notification.hasClass("hide"), "API : close");
47 widget.notification("open");
48 notification = widget.children( elem );
50 /*for coverage open notification when it is already open*/
51 widget.notification("open");
52 notification.trigger("vmouseup");
53 notification = widget.children( elem );
54 ok( notification.hasClass("hide"), "Hide when click the notification");
56 if ( type == ' ticker') {
57 widget.notification("open");
58 closebutton = widget.find(':jqmData(role=button)');
59 closebutton.trigger("vmouseup");
60 notification = widget.children( elem );
61 ok( notification.hasClass("hide"), "Hide when click on the close button");
64 text = notification.children("p");
65 if ( type === "smallpopup") {
66 ok( $( text[0] ).hasClass("ui-smallpopup-text-bg"), "Text");
67 widget.notification('text', 'Text21');
68 ok( $( text[0] ).hasClass("ui-smallpopup-text-bg"), "Text21");
69 equal( widget.notification('text')[0], "Text21", "API : text - smallpopup");
70 equal( text[0].innerHTML, "Text21", "API : text - smallpopup");
72 ok( $( text[0] ).hasClass("ui-ticker-text1-bg"), "Top Text");
73 ok( $( text[1] ).hasClass("ui-ticker-text2-bg"), "Bottom Text");
75 widget.notification('text', 'Text31', 'Text32');
76 ok( $( text[0] ).hasClass("ui-ticker-text1-bg"), "Text31", "API : text- ticker");
77 ok( $( text[1] ).hasClass("ui-ticker-text2-bg"), "Text32", "API : text- ticker");
78 equal( text[0].innerHTML, "Text31", "API : text - ticker");
79 equal( text[1].innerHTML, "Text32", "API : text - ticker");
80 equal( widget.notification('text')[0], "Text31", "API : text - ticker");
81 equal( widget.notification('text')[1], "Text32", "API : text - ticker");
84 equal(widget.jqmData('icon'), '02_icon.png', "API : icon , initial check") ;
85 widget.notification('icon', '03_icon.png');
86 equal(widget.find('img').attr("src"), '03_icon.png', "API : icon , new icon is set") ;
89 widget.notification("destroy");
90 notification = widget.children( elem );
91 ok( !notification.hasClass("show") || !notification.hasClass("hide"), "destroy check");
94 test("smallpopup", function () {
95 $('#notifiaction0').page();
96 unit_notification( $("#smallpopup"), "smallpopup");
97 unit_notification( $("#smallpopup2"), "smallpopup");
98 unit_notification( $("#smallpopup3"), "smallpopup");
101 test("tickernoti", function () {
102 $('#notifiaction1').page();
103 unit_notification( $("#tickernoti"), "ticker");
104 unit_notification( $("#tickernoti2"), "ticker");
105 unit_notification( $("#tickernoti3"), "ticker");