2 * navigationbar unit tests
4 /*jslint browser: true*/
5 /*global $, jQuery, test, equal, ok*/
7 module("Navigationbar");
9 var unit_navigationbar = function ( widget, anchorCount, position, extendedValue ) {
11 var created_navigationbar = $( widget );
12 ok( created_navigationbar, "Create");
14 /* Check Parameters */
15 equal( created_navigationbar.jqmData("nstest-role"), position, "Basic test");
17 if ( extendedValue ) {
18 equal( created_navigationbar.find("input").length, anchorCount, "Groupcontrol button test");
20 equal( created_navigationbar.children("a").length, anchorCount, "button test");
24 test("navigationbar no button test -header", function ( ) {
25 unit_navigationbar( $("#normalnavigation1"), 0, 'header');
28 test("navigationbar one button test -header", function ( ) {
29 unit_navigationbar( $("#normalnavigation2"), 1, 'header');
32 test("navigationbar two button test -header", function ( ) {
33 unit_navigationbar( $("#normalnavigation3"), 2 , 'header');
36 test("navigationbar three button test -header", function ( ) {
37 unit_navigationbar( $("#normalnavigation4"), 3 , 'header');
40 test("navigationbar extended two button test -header", function ( ) {
41 unit_navigationbar( $("#extendedstyle2btn"), 2, 'header', true );
44 test("navigationbar extended three button test - header", function ( ) {
45 unit_navigationbar( $("#extendedstyle3btn"), 3, 'header', true );
48 test("navigationbar extended four button test -header", function ( ) {
49 unit_navigationbar( $("#extendedstyle4btn"), 4, 'header', true );
52 test("navigationbar no button test -header - Dynamic", function ( ) {
54 var markup = '<h1>Navigationbar Test - markup</h1>';
55 $('#normalnavigation11').append( markup ).trigger('create');
57 unit_navigationbar( $("#normalnavigation11"), 0, 'header');
60 test("navigationbar extended four button test -header- Dymanic", function ( ) {
62 var markup = '<div data-role= "fieldcontain">' +
63 '<fieldset data-role= "controlgroup"data-type= "horizontal">' +
64 '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment1"value= "on"checked= "checked"/>' +
65 '<label for= "segment1">All</label>' +
66 '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment2"value= "off"/>' +
67 '<label for= "segment2">Call</label>' +
68 '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment3"value= "off"/>' +
69 '<label for= "segment3">Save</label>' +
70 '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment4"value= "off"/>' +
71 '<label for= "segment4">Back</label>' +
75 $('#extendedstyle5btn').append( markup ).trigger('create');
76 $('#extendedstyle5btn').find(":jqmData(role=fieldcontain)").trigger('create');
77 unit_navigationbar( $("#extendedstyle5btn"), 4, 'header', true );
81 test("navigationbar no button test -footer", function ( ) {
82 unit_navigationbar( $("#normalnavigation12"), 0 , 'footer');
85 test("navigationbar one button test -footer", function ( ) {
86 unit_navigationbar( $("#normalnavigation22"), 1 , 'footer');
89 test("navigationbar two button test -footer", function ( ) {
90 unit_navigationbar( $("#normalnavigation32"), 2 , 'footer');
93 test("navigationbar three button test -footer", function ( ) {
94 unit_navigationbar( $("#normalnavigation42"), 3 , 'footer');
97 test("navigationbar extended two button test -footer", function ( ) {
98 unit_navigationbar( $("#extendedstyle22btn"), 2 , 'footer', true );
101 test("navigationbar extended three button test -footer", function ( ) {
102 unit_navigationbar( $("#extendedstyle32btn"), 3 , 'footer', true );
105 test("navigationbar extended four button test -footer", function ( ) {
106 unit_navigationbar( $("#extendedstyle42btn"), 4 , 'footer', true );
109 test("navigationbar no button test -footer - Dynamic", function ( ) {
111 var markup = '<h1>Navigationbar Test - markup</h1>';
112 $('#normalnavigation111').append( markup ).trigger('create');
114 unit_navigationbar( $("#normalnavigation111"), 0 , 'footer');
117 test("navigationbar extended four button test -footer- Dymanic", function ( ) {
119 var markup = '<div data-role= "fieldcontain">' +
120 '<fieldset data-role= "controlgroup"data-type= "horizontal">' +
121 '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment1"value= "on"checked= "checked"/>' +
122 '<label for= "segment1">All</label>' +
123 '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment2"value= "off"/>' +
124 '<label for= "segment2">Call</label>' +
125 '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment3"value= "off"/>' +
126 '<label for= "segment3">Save</label>' +
127 '<input type= "radio"name= "radio-view-8"data-icon= "segment-titlestyle-segonly"id= "segment4"value= "off"/>' +
128 '<label for= "segment4">Back</label>' +
132 $('#extendedstyle52btn').append( markup ).trigger('create');
133 $('#extendedstyle52btn').find(":jqmData(role=fieldcontain)").trigger('create');
134 unit_navigationbar( $("#extendedstyle52btn"), 4 , 'footer', true );