Changeset 2113:a134102bfd9a for tests/functional/spec/page_tabs.js
- Timestamp:
- 09/27/13 16:18:17 (12 years ago)
- Branch:
- default
- Children:
- 2114:7f63aa8eeebf, 2134:b3b9847a5d45
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/functional/spec/page_tabs.js
r2054 r2113 41 41 expect($('#part-user-favorites')).not.toBeVisible(); 42 42 43 $ ('.part-tabs ul li a[href="#user-profile"]').click();43 $.pageTabs.clickTab('user-profile'); 44 44 expect($('#part-tabs-user-profile')).toHaveClass('part-tabs-active'); 45 45 expect($('#part-user-options')).not.toBeVisible(); … … 51 51 loadStyleFixtures('default.css'); 52 52 53 spyOn(jQuery , 'pageTabsGetHash').andReturn('user-favorites');53 spyOn(jQuery.pageTabs, 'getLocationHash').andReturn('user-favorites'); 54 54 $.pageTabs(); 55 55 expect($('#part-user-options')).not.toBeVisible(); … … 57 57 expect($('#part-user-favorites')).toBeVisible(); 58 58 }); 59 60 it("Must trigger event onetabload only the first time the tab is loaded", function() { 61 loadFixtures('tabs.html'); 62 loadStyleFixtures('default.css'); 63 64 var user_option_count_call = user_profile_count_call = user_favorites_count_call = 0; 65 spyOn(jQuery.fn, 'onetabload').andCallThrough(); 66 $('#user-options').onetabload(function() {user_option_count_call++;}); 67 $('#user-profile').onetabload(function() {user_profile_count_call++;}); 68 $('#user-favorites').onetabload(function() {user_favorites_count_call++;}); 69 70 $.pageTabs('user-options'); 71 expect(jQuery.fn.onetabload).toHaveBeenCalled(); 72 $.pageTabs.clickTab('user-profile'); 73 $.pageTabs.clickTab('user-options'); 74 75 expect(user_option_count_call).toBe(1); 76 expect(user_profile_count_call).toBe(1); 77 expect(user_favorites_count_call).toBe(0); 78 }); 79 80 it("Must trigger event tabload every first time the tab is loaded", function() { 81 loadFixtures('tabs.html'); 82 loadStyleFixtures('default.css'); 83 84 spyOn(jQuery.fn, 'tabload').andCallThrough(); 85 86 var user_option_count_call = user_profile_count_call = user_favorites_count_call = 0; 87 $('#user-options').tabload(function() {user_option_count_call++;}); 88 $('#user-profile').tabload(function() {user_profile_count_call++;}); 89 $('#user-favorites').tabload(function() {user_favorites_count_call++;}); 90 91 $.pageTabs('user-options'); 92 $.pageTabs.clickTab('user-profile'); 93 $.pageTabs.clickTab('user-options'); 94 95 expect(user_option_count_call).toBe(2); 96 expect(user_profile_count_call).toBe(1); 97 expect(user_favorites_count_call).toBe(0); 98 }); 99 100 it("Must keeps history of navigation in tabs", function() { 101 loadFixtures('tabs.html'); 102 loadStyleFixtures('default.css'); 103 104 var navigation = ['user-options', 'user-profile', 'user-favorites']; 105 var current_index = 0; 106 107 $.pageTabs(navigation[current_index]); 108 current_index++; 109 expect($('#part-user-options')).toBeVisible(); 110 expect($('#part-user-profile')).not.toBeVisible(); 111 expect($('#part-user-favorites')).not.toBeVisible(); 112 113 $.pageTabs.clickTab(navigation[current_index]); 114 current_index++; 115 expect($('#part-user-options')).not.toBeVisible(); 116 expect($('#part-user-profile')).toBeVisible(); 117 expect($('#part-user-favorites')).not.toBeVisible(); 118 119 $.pageTabs.clickTab(navigation[current_index]); 120 expect($('#part-user-options')).not.toBeVisible(); 121 expect($('#part-user-profile')).not.toBeVisible(); 122 expect($('#part-user-favorites')).toBeVisible(); 123 124 // simulate back : window.history.back(); 125 current_index--; 126 spyOn(jQuery.pageTabs, 'getLocationHash').andReturn(navigation[current_index]); 127 jQuery.event.trigger('hashchange'); 128 129 expect($('#part-user-options')).not.toBeVisible(); 130 expect($('#part-user-profile')).toBeVisible(); 131 expect($('#part-user-favorites')).not.toBeVisible(); 132 }); 59 133 }); 60 134
Note: See TracChangeset
for help on using the changeset viewer.