| 
									
										
										
										
											2016-10-06 23:25:52 +01:00
										 |  |  | 'use strict'; // necessary for es6 output in node 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { browser, element, by } from 'protractor'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-05 09:27:10 +03:00
										 |  |  | describe('Component Style Tests', function () { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   beforeAll(function () { | 
					
						
							|  |  |  |     browser.get(''); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('scopes component styles to component view', function() { | 
					
						
							| 
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 |  |  |     let componentH1 = element(by.css('hero-app > h1')); | 
					
						
							|  |  |  |     let externalH1 = element(by.css('body > h1')); | 
					
						
							| 
									
										
										
										
											2016-04-05 09:27:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect(componentH1.getCssValue('fontWeight')).toEqual('normal'); | 
					
						
							|  |  |  |     expect(externalH1.getCssValue('fontWeight')).not.toEqual('normal'); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('allows styling :host element', function() { | 
					
						
							| 
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 |  |  |     let host = element(by.css('hero-details')); | 
					
						
							| 
									
										
										
										
											2016-04-05 09:27:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect(host.getCssValue('borderWidth')).toEqual('1px'); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('supports :host() in function form', function() { | 
					
						
							| 
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 |  |  |     let host = element(by.css('hero-details')); | 
					
						
							| 
									
										
										
										
											2016-04-05 09:27:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     host.element(by.buttonText('Activate')).click(); | 
					
						
							|  |  |  |     expect(host.getCssValue('borderWidth')).toEqual('3px'); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('allows conditional :host-context() styling', function() { | 
					
						
							| 
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 |  |  |     let h2 = element(by.css('hero-details h2')); | 
					
						
							| 
									
										
										
										
											2016-04-05 09:27:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect(h2.getCssValue('backgroundColor')).toEqual('rgba(238, 238, 255, 1)'); // #eeeeff
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('styles both view and content children with /deep/', function() { | 
					
						
							| 
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 |  |  |     let viewH3 = element(by.css('hero-team h3')); | 
					
						
							|  |  |  |     let contentH3 = element(by.css('hero-controls h3')); | 
					
						
							| 
									
										
										
										
											2016-04-05 09:27:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect(viewH3.getCssValue('fontStyle')).toEqual('italic'); | 
					
						
							|  |  |  |     expect(contentH3.getCssValue('fontStyle')).toEqual('italic'); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('includes styles loaded with CSS @import', function() { | 
					
						
							| 
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 |  |  |     let host = element(by.css('hero-details')); | 
					
						
							| 
									
										
										
										
											2016-04-05 09:27:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect(host.getCssValue('padding')).toEqual('10px'); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('processes template inline styles', function() { | 
					
						
							| 
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 |  |  |     let button = element(by.css('hero-controls button')); | 
					
						
							|  |  |  |     let externalButton = element(by.css('body > button')); | 
					
						
							| 
									
										
										
										
											2016-04-05 09:27:10 +03:00
										 |  |  |     expect(button.getCssValue('backgroundColor')).toEqual('rgba(255, 255, 255, 1)'); // #ffffff
 | 
					
						
							|  |  |  |     expect(externalButton.getCssValue('backgroundColor')).not.toEqual('rgba(255, 255, 255, 1)'); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('processes template <link>s', function() { | 
					
						
							| 
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 |  |  |     let li = element(by.css('hero-team li:first-child')); | 
					
						
							|  |  |  |     let externalLi = element(by.css('body > ul li')); | 
					
						
							| 
									
										
										
										
											2016-04-05 09:27:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect(li.getCssValue('listStyleType')).toEqual('square'); | 
					
						
							|  |  |  |     expect(externalLi.getCssValue('listStyleType')).not.toEqual('square'); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('supports relative loading with moduleId', function() { | 
					
						
							| 
									
										
										
										
											2016-05-30 11:05:09 -07:00
										 |  |  |     let host = element(by.css('quest-summary')); | 
					
						
							| 
									
										
										
										
											2016-04-05 09:27:10 +03:00
										 |  |  |     expect(host.getCssValue('color')).toEqual('rgba(255, 255, 255, 1)'); // #ffffff
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }); |