2017-04-12 15:31:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								'use strict'; // necessary for es6 output in node
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-06 23:25:52 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import { browser, element, by } from 'protractor';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								describe('Pipes', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  beforeAll(function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    browser.get('');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  it('should open correctly', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expect(element.all(by.tagName('h1')).get(0).getText()).toEqual('Pipes');
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expect(element(by.css('hero-birthday p')).getText()).toEqual(`The hero's birthday is Apr 15, 1988`);
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  it('should show 4 heroes', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(element.all(by.css('hero-list div')).count()).toEqual(4);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  it('should show a familiar hero in json', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(element(by.cssContainingText('hero-list p', 'Heroes as JSON')).getText()).toContain('Bombasto');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  it('should show alternate birthday formats', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expect(element(by.cssContainingText('my-app > p', `The hero's birthday is Apr 15, 1988`)).isDisplayed()).toBe(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(element(by.cssContainingText('my-app > p', `The hero's birthday is 04/15/88`)).isDisplayed()).toBe(true);
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  it('should be able to toggle birthday formats', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let birthDayEle = element(by.css('hero-birthday2 > p'));
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    expect(birthDayEle.getText()).toEqual(`The hero's birthday is 4/15/1988`);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    let buttonEle = element(by.cssContainingText('hero-birthday2 > button', 'Toggle Format'));
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(buttonEle.isDisplayed()).toBe(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    buttonEle.click().then(function() {
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(birthDayEle.getText()).toEqual(`The hero's birthday is Friday, April 15, 1988`);
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  it('should be able to chain and compose pipes', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let chainedPipeEles = element.all(by.cssContainingText('my-app p', `The chained hero's`));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(chainedPipeEles.count()).toBe(3, 'should have 3 chained pipe examples');
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(chainedPipeEles.get(0).getText()).toContain('APR 15, 1988');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(chainedPipeEles.get(1).getText()).toContain('FRIDAY, APRIL 15, 1988');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(chainedPipeEles.get(2).getText()).toContain('FRIDAY, APRIL 15, 1988');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  it('should be able to use ExponentialStrengthPipe pipe', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let ele = element(by.css('power-booster p'));
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(ele.getText()).toContain('Super power boost: 1024');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  it('should be able to use the exponential calculator', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let eles = element.all(by.css('power-boost-calculator input'));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    let baseInputEle = eles.get(0);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    let factorInputEle = eles.get(1);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    let outputEle = element(by.css('power-boost-calculator p'));
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    baseInputEle.clear().then(function() {
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-06 23:25:52 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      baseInputEle.sendKeys('7');
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      return factorInputEle.clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }).then(function() {
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-06 23:25:52 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      factorInputEle.sendKeys('3');
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(outputEle.getText()).toContain('343');
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-03 11:32:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-12 15:31:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  it('should support flying heroes (pure) ', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let nameEle = element(by.css('flying-heroes input[type="text"]'));
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-01 18:11:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let canFlyCheckEle = element(by.css('flying-heroes #can-fly'));
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let mutateCheckEle = element(by.css('flying-heroes #mutate'));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    let resetEle = element(by.css('flying-heroes button'));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    let flyingHeroesEle = element.all(by.css('flying-heroes #flyers div'));
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(canFlyCheckEle.getAttribute('checked')).toEqual('true', 'should default to "can fly"');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(mutateCheckEle.getAttribute('checked')).toEqual('true', 'should default to mutating array');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(flyingHeroesEle.count()).toEqual(2, 'only two of the original heroes can fly');
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-06 23:25:52 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    nameEle.sendKeys('test1\n');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(flyingHeroesEle.count()).toEqual(2, 'no change while mutating array');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    mutateCheckEle.click().then(function() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      nameEle.sendKeys('test2\n');
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(flyingHeroesEle.count()).toEqual(4, 'not mutating; should see both adds');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      expect(flyingHeroesEle.get(2).getText()).toContain('test1');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      expect(flyingHeroesEle.get(3).getText()).toContain('test2');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      return resetEle.click();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    .then(function() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       expect(flyingHeroesEle.count()).toEqual(2, 'reset should restore orginal flying heroes');
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-12 15:31:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  it('should support flying heroes (impure) ', function () {
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let nameEle = element(by.css('flying-heroes-impure input[type="text"]'));
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let canFlyCheckEle = element(by.css('flying-heroes-impure #can-fly'));
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    let mutateCheckEle = element(by.css('flying-heroes-impure #mutate'));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    let flyingHeroesEle = element.all(by.css('flying-heroes-impure #flyers div'));
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(canFlyCheckEle.getAttribute('checked')).toEqual('true', 'should default to "can fly"');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(mutateCheckEle.getAttribute('checked')).toEqual('true', 'should default to mutating array');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(flyingHeroesEle.count()).toEqual(2, 'only two of the original heroes can fly');
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-06 23:25:52 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    nameEle.sendKeys('test1\n');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(flyingHeroesEle.count()).toEqual(3, 'new flying hero should show in mutating array');
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-13 13:44:14 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  it('should show an async hero message', function () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    expect(element.all(by.tagName('hero-message')).get(0).getText()).toContain('hero');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-12-20 13:17:16 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 |