| 
									
										
										
										
											2016-12-07 21:41:27 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-03 13:37:20 +01:00
										 |  |  | import {modifiedInIvy} from '@angular/private/testing'; | 
					
						
							| 
									
										
										
										
											2016-12-07 21:41:27 -08:00
										 |  |  | import {$, ExpectedConditions, browser, by, element} from 'protractor'; | 
					
						
							| 
									
										
										
										
											2019-01-28 21:59:25 +01:00
										 |  |  | import {verifyNoBrowserErrors} from '../../../../test-utils'; | 
					
						
							| 
									
										
										
										
											2016-12-07 21:41:27 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | function waitForElement(selector: string) { | 
					
						
							|  |  |  |   const EC = ExpectedConditions; | 
					
						
							|  |  |  |   // Waits for the element with id 'abc' to be present on the dom.
 | 
					
						
							|  |  |  |   browser.wait(EC.presenceOf($(selector)), 20000); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe('ngIf', () => { | 
					
						
							| 
									
										
										
										
											2019-01-28 21:59:25 +01:00
										 |  |  |   const URL = '/ngIf'; | 
					
						
							| 
									
										
										
										
											2016-12-07 21:41:27 -08:00
										 |  |  |   afterEach(verifyNoBrowserErrors); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('ng-if-simple', () => { | 
					
						
							| 
									
										
										
										
											2016-12-09 14:42:39 -08:00
										 |  |  |     let comp = 'ng-if-simple'; | 
					
						
							| 
									
										
										
										
											2016-12-07 21:41:27 -08:00
										 |  |  |     it('should hide/show content', () => { | 
					
						
							|  |  |  |       browser.get(URL); | 
					
						
							|  |  |  |       waitForElement(comp); | 
					
						
							|  |  |  |       expect(element.all(by.css(comp)).get(0).getText()).toEqual('hide show = true\nText to show'); | 
					
						
							|  |  |  |       element(by.css(comp + ' button')).click(); | 
					
						
							|  |  |  |       expect(element.all(by.css(comp)).get(0).getText()).toEqual('show show = false'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('ng-if-else', () => { | 
					
						
							| 
									
										
										
										
											2016-12-09 14:42:39 -08:00
										 |  |  |     let comp = 'ng-if-else'; | 
					
						
							| 
									
										
										
										
											2016-12-07 21:41:27 -08:00
										 |  |  |     it('should hide/show content', () => { | 
					
						
							|  |  |  |       browser.get(URL); | 
					
						
							|  |  |  |       waitForElement(comp); | 
					
						
							|  |  |  |       expect(element.all(by.css(comp)).get(0).getText()).toEqual('hide show = true\nText to show'); | 
					
						
							|  |  |  |       element(by.css(comp + ' button')).click(); | 
					
						
							|  |  |  |       expect(element.all(by.css(comp)).get(0).getText()) | 
					
						
							|  |  |  |           .toEqual('show show = false\nAlternate text while primary text is hidden'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('ng-if-then-else', () => { | 
					
						
							| 
									
										
										
										
											2016-12-09 14:42:39 -08:00
										 |  |  |     let comp = 'ng-if-then-else'; | 
					
						
							| 
									
										
										
										
											2019-01-28 22:00:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-19 14:12:35 -08:00
										 |  |  |     it('should hide/show content', () => { | 
					
						
							|  |  |  |       browser.get(URL); | 
					
						
							|  |  |  |       waitForElement(comp); | 
					
						
							|  |  |  |       expect(element.all(by.css(comp)).get(0).getText()) | 
					
						
							|  |  |  |           .toEqual('hideSwitch Primary show = true\nPrimary text to show'); | 
					
						
							|  |  |  |       element.all(by.css(comp + ' button')).get(1).click(); | 
					
						
							|  |  |  |       expect(element.all(by.css(comp)).get(0).getText()) | 
					
						
							|  |  |  |           .toEqual('hideSwitch Primary show = true\nSecondary text to show'); | 
					
						
							|  |  |  |       element.all(by.css(comp + ' button')).get(0).click(); | 
					
						
							|  |  |  |       expect(element.all(by.css(comp)).get(0).getText()) | 
					
						
							|  |  |  |           .toEqual('showSwitch Primary show = false\nAlternate text while primary text is hidden'); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2016-12-07 21:41:27 -08:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('ng-if-let', () => { | 
					
						
							| 
									
										
										
										
											2016-12-09 14:42:39 -08:00
										 |  |  |     let comp = 'ng-if-let'; | 
					
						
							| 
									
										
										
										
											2016-12-07 21:41:27 -08:00
										 |  |  |     it('should hide/show content', () => { | 
					
						
							|  |  |  |       browser.get(URL); | 
					
						
							|  |  |  |       waitForElement(comp); | 
					
						
							|  |  |  |       expect(element.all(by.css(comp)).get(0).getText()) | 
					
						
							|  |  |  |           .toEqual('Next User\nWaiting... (user is null)'); | 
					
						
							|  |  |  |       element(by.css(comp + ' button')).click(); | 
					
						
							|  |  |  |       expect(element.all(by.css(comp)).get(0).getText()).toEqual('Next User\nHello Smith, John!'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }); |